Created
September 27, 2012 00:53
-
-
Save lsparrish/3791537 to your computer and use it in GitHub Desktop.
IO Test
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
| 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