Created
May 20, 2011 04:35
-
-
Save maoe/982363 to your computer and use it in GitHub Desktop.
unsafeInterleaveIOがまずいのがわかるコード辺
This file contains 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
$ runhaskell UnsafeIO.hs | |
unsafeHello #1 | |
unsafeHello #2 | |
Hello, World | |
Hello, World #2 | |
() |
This file contains 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
module Main where | |
import System.IO.Unsafe | |
hello = do | |
unit <- putStrLn "Hello, World" | |
putStrLn "Hello, World #2" | |
return unit | |
unsafeHello = unsafeInterleaveIO hello | |
main = do | |
putStrLn "unsafeHello #1" | |
unsafeHello -- なにも表示されない | |
putStrLn "unsafeHello #2" | |
unsafeHello >>= print -- 表示される |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment