Created
May 22, 2017 07:27
-
-
Save nobsun/0d52cf58ba78358b4740e9f6e694bc46 to your computer and use it in GitHub Desktop.
lazy IO と imperative programming とが相性がわるい例
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
module Main where | |
import System.IO.Unsafe | |
lazy :: IO a -> IO a | |
lazy = unsafeInterleaveIO | |
main :: IO () | |
main = do | |
{ input1 <- getLine | |
; input2 <- getLine | |
; putStrLn ("out: " ++ input2) | |
; putStrLn "1.------" | |
; input3 <- lazy getLine | |
; input4 <- lazy getLine | |
; putStrLn ("out: " ++ input4) | |
; putStrLn "2.------" | |
} | |
{- ^ | |
>>> :main | |
foo | |
bar | |
out: bar | |
1.------ | |
baz | |
out: baz | |
2.------ | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment