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

Working with IO monad

In the recipes that we saw earlier, we all worked with IO, and used functions such as putStrLn :: String -> IO () or print :: Show a => a -> IO ()We already know that these functions print the string or a value to standard output.

In this recipe, we will open a file, read it line by line, and output it on the stdout along with the line number. We will also understand how IO works as a monad and how IO allows a Haskell program to interact with the outside world.

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