-
-
Save fujimura/3cec640952ee67d0beb0 to your computer and use it in GitHub Desktop.
Interact with stdin
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
import System.IO | |
import System.IO.Temp | |
main :: IO () | |
main = do | |
withSystemTempFile "uuu" $ \path handle -> do | |
hPutStrLn handle "hello\nbye" | |
hClose handle | |
handle' <- openFile path ReadMode | |
go handle' stdout | |
go :: Handle -> Handle -> IO () | |
go i o = do | |
l <- hGetLine i | |
hPutStrLn o l |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment