Skip to content

Instantly share code, notes, and snippets.

@fujimura
Last active October 27, 2015 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fujimura/3cec640952ee67d0beb0 to your computer and use it in GitHub Desktop.
Save fujimura/3cec640952ee67d0beb0 to your computer and use it in GitHub Desktop.
Interact with stdin
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