Created
November 21, 2011 18:45
-
-
Save KirinDave/1383510 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
halp :: Int -> IO [Int] | |
halp 0 = return [] | |
halp a = do | |
putStrLn "Tick in IO [Int]" | |
y <- halp (a - 1) | |
return $ 1 : y | |
halphalp :: Int -> [IO Int] | |
halphalp n = replicate n $ (putStrLn "Tick in [IO Int]" >> return 1) | |
main = do | |
putStrLn "The behavior of IO [Int]" | |
x <- halp 5 | |
putStrLn (show $ head x) | |
-- We saw 5 ticks but printed only the first value. | |
putStrLn "The behavior of [IO Int]" | |
let y = halphalp 5 -- Note that this is a let, not a do! | |
z <- head y -- Now let's execute ONE of these. | |
putStrLn (show z) -- We only saw one tick. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment