O'Reilly logo

Haskell Cookbook by Yogesh Sajanikar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

We have been using IO and functions related to IO in a limited way in our previous recipes. The usage was limited to printing the output using either putStrLn or print. We should spend some time to understand what IO is and how it is inevitable for a Haskell program. 

Haskell works with pure functions without side effects. It means that the evaluation of pure functions does not affect the outside world in any way. To be able to interact with the outside world, the outside world would need to contain memory, a console, file I/O, networking, and so on. The IO monad enables a Haskell program to interact with the outside world. IO monad is the gateway for pure Haskell functions to the outside world. 

By interacting with IO, Haskell ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required