Skip to content

Instantly share code, notes, and snippets.

@m2ym
Created July 28, 2010 07:23
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 m2ym/493681 to your computer and use it in GitHub Desktop.
Save m2ym/493681 to your computer and use it in GitHub Desktop.
import Control.Monad
import System.IO
import System.IO.Unsafe
ifte :: Monad m => m Bool -> m a -> m a -> m a
ifte c t e = c >>= \b -> if b then t else e
getLinesI :: IO [String]
getLinesI = unsafeInterleaveIO $ ifte isEOF (return []) (liftM2 (:) getLine getLinesI)
main = getLinesI >>= mapM_ putStrLn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment