Created
September 18, 2010 22:12
-
-
Save LindseyB/586098 to your computer and use it in GitHub Desktop.
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
type World = String | |
type Player = String | |
initWorld :: IO World | |
initWorld = return "World" | |
initPlayer :: IO Player | |
initPlayer = return "Player" | |
act :: World -> String -> World | |
act w i = w | |
hasWon :: World -> Bool | |
hasWon w = True | |
getInput :: IO String | |
getInput = getLine | |
gameLoop :: Int -> World -> Player -> IO World | |
gameLoop n w p | |
| hasWon w == (n == 10) = return w | |
| otherwise = do | |
i <- getInput | |
putStrLn ("Hey " ++ show n ++ " " ++ i) | |
hFlush | |
gameLoop (n + 1) (act w i) p | |
main = do | |
world <- initWorld | |
player <- initPlayer | |
gameLoop 0 world player | |
putStr "Goodbye!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment