Skip to Content
Get Programming with Haskell
book

Get Programming with Haskell

by Will Kurt
March 2018
Beginner
616 pages
16h 53m
English
Manning Publications
Content preview from Get Programming with Haskell

Lesson 21. Hello World!—introducing IO types

After reading lesson 21, you’ll be able to

  • Understand how Haskell handles I/O by using IO types
  • Use do-notation to perform I/O
  • Write pure programs that interact with the real world

In lesson 1, you saw a basic example of a Hello World program. In this lesson, you’ll revisit a similar program to get a better sense of how I/O works in Haskell. Here’s an example program using I/O that reads a name from the command line and prints out "Hello <name>!".

Listing 21.1. A simple Hello World program
helloPerson :: String -> String helloPerson name = "Hello" ++ " " ++ name ++ "!" main :: IO () main = do putStrLn "Hello! What's your name?" name <- getLine let statement = helloPerson name putStrLn statement ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Get Programming with Go

Get Programming with Go

Nathan Youngman, Roger Peppe
Effective Haskell

Effective Haskell

Rebecca Skinner

Publisher Resources

ISBN: 9781617293764Publisher SupportOtherPublisher WebsiteSupplemental ContentErrata PagePurchase Link