Last active
August 29, 2015 14:08
-
-
Save CarstenKoenig/606771cd7b6a9123bea3 to your computer and use it in GitHub Desktop.
IoKnot?
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
module IoKnot where | |
import System.IO | |
-- this is how you could make your version *working* (well not really, the mapM is really strange) | |
f :: [String] -> IO [String] | |
f = mapM $ \x -> putStr x >> putStr ": " >> hFlush stdout >> getLine | |
g :: [String] -> IO () | |
g x = do | |
x' <- f ("start":x) | |
g x' | |
-- but this is what I think you really want to do | |
dialog :: String -> IO () | |
dialog prompt = do | |
putStr prompt | |
putStr ": " | |
hFlush stdout | |
next <- getLine | |
dialog next | |
main :: IO () | |
main = do | |
-- yours: g [] | |
-- what I think: | |
dialog "start" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment