Skip to content

Instantly share code, notes, and snippets.

@CarstenKoenig
Last active August 29, 2015 14:08
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 CarstenKoenig/606771cd7b6a9123bea3 to your computer and use it in GitHub Desktop.
Save CarstenKoenig/606771cd7b6a9123bea3 to your computer and use it in GitHub Desktop.
IoKnot?
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