Created
August 12, 2013 05:10
-
-
Save joseph-montanez/6208361 to your computer and use it in GitHub Desktop.
compiles but does nothing?
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
data GameState = Running | Paused | Stopped | |
data World = World { | |
gameState :: GameState, | |
loopCount :: Int | |
} | |
gameloop world = | |
case gameState world of | |
Running -> do | |
userInput <- getLine | |
case userInput of | |
"pause" -> gameloop world { gameState = Paused } | |
"stop" -> gameloop world { gameState = Stopped } | |
_ -> do | |
let newCount = loopCount world + 1 | |
putStrLn ("You typed: " ++ userInput) | |
putStrLn ("I've looped " ++ show newCount ++ " times") | |
gameloop world { loopCount = newCount } | |
Paused -> gameloop world | |
Stopped -> return world | |
main = do | |
let world = gameloop $ World Running 0 | |
putStrLn "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment