Skip to content

Instantly share code, notes, and snippets.

@lsparrish
Created September 27, 2012 00:53
Show Gist options
  • Select an option

  • Save lsparrish/3791537 to your computer and use it in GitHub Desktop.

Select an option

Save lsparrish/3791537 to your computer and use it in GitHub Desktop.
IO Test
import IO
-- IO playground
intro :: String
intro = "Hello, welcome to the playground."
prompt = "\n->"
--
quit :: IO ()
quit = do putStr "\nGoodbye."
loop :: IO ()
loop = do
putStr prompt
l <- getLine'
if l == "bye"
then quit
else do
putStr l
loop
getLine' :: IO String
getLine' = do c <- getChar
if c == '\b'
then do putStr "\b \b\b\b"
else return ()
if c == '\t'
then return ""
else do l <- getLine'
return (c:l)
main :: IO ()
main = do
-- hSetBuffering stdin (BlockBuffering (Just 100))
-- hSetBuffering stdout (BlockBuffering (Just 100))
putStr intro
loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment