10. Functions
Give me a list of a
• reverse :: [a] -> [a]
• reverse [] = []
• reverse (x:xs) = reverse xs ++ [x]
11. Functions
Give me a list of a And I’ll return a
list of a
• reverse :: [a] -> [a]
• reverse [] = []
• reverse (x:xs) = reverse xs ++ [x]
12. Functions
Give me a list of a And I’ll return a
list of a
• reverse :: [a] -> [a]
• reverse [] = []
• reverse (x:xs) = reverse xs ++ [x]
Pattern Matching
19. Doing I/O
• putStrLn :: String -> IO ()
The IO type shows us it’s not pure
20. Doing I/O
(>>=) :: IO a -> (a -> IO b) -> IO b
main = putStrLn "hello! what's your name?"
>>= () -> getLine
>>= name -> putStrLn ("hello, " ++ name)
21. Doing I/O
(>>=) :: IO a -> (a -> IO b) -> IO b
main = putStrLn "hello! what's your name?"
>>= () -> getLine
>>= name -> putStrLn ("hello, " ++ name)
22. Doing I/O
main = do
putStrLn "hello! what's your name?"
name <- getLine
putStrLn ("hello, " ++ name)