Haskell. Chapter 8. Input and Output. What are I/O actions? How do I/O actions enable us to do I/O? When are I/O actions actually performed?. Review of Functional Language characteristics. Haskell is purely = putStrLn "Hello World!"
At the command prompt
main2 = do
putStrLn "Hello, what's your name?"
name <- getLine
putStrLn $ "Zis is your future: " ++ tellFortune name
tellFortune name
| name == "Lucky" = name ++ ",you will win a million dollars"
| otherwise = name ++ ", you will have no money but be happy"
import Data.Char
main3 = do
putStrLn "What's your first name? "
firstName <- getLine
putStrLn "What's your last name? "
lastName <- getLine
let bigFirstName = map toUpperfirstName
let bigLastName = map toUpperlastName
putStrLn $ "hey " ++ bigFirstName ++ " "
++ bigLastName
++ ", how are you?“
main4 = do
line <- getLine
if null line
then return ()
else do
putStrLn $ reverseWords line
main4
reverseWords :: String -> String
reverseWords = unwords . map reverse . words
main5 = do
return ()
return "HAHAHA"
line <- getLine
return "BLAH BLAH"
return 4
putStrLn line
main6 = do
a <- return "Hello"
b <- return "World"
putStrLn $ a ++ " " ++ b