Skip to content

Instantly share code, notes, and snippets.

@cblp
Created April 26, 2016 13:28
Show Gist options
  • Save cblp/324cd56609f5f6f36fd38e360516eeb7 to your computer and use it in GitHub Desktop.
Save cblp/324cd56609f5f6f36fd38e360516eeb7 to your computer and use it in GitHub Desktop.
import System.IO.Unsafe
heavy y = unsafePerformIO $ do
putStrLn "heavy"
return y
f1 x = heavy 10 + x
f2 x = let y = heavy 10 in y + x
f3 x = y + x where y = heavy 10
main = do
print $ map f1 [1..3]
print $ map f2 [1..3]
print $ map f3 [1..3]
heavy
heavy
heavy
[11,12,13]
heavy
heavy
heavy
[11,12,13]
heavy
heavy
heavy
[11,12,13]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment