Skip to content

Instantly share code, notes, and snippets.

@joseph-montanez
Created August 6, 2013 15:29
Show Gist options
  • Save joseph-montanez/6165530 to your computer and use it in GitHub Desktop.
Save joseph-montanez/6165530 to your computer and use it in GitHub Desktop.
Main.hs:16:41:
Couldn't match expected type `[Char]' with actual type `IO ()'
In the return type of a call of `putStrLn'
In the first argument of `(++)', namely `putStrLn "You typed: "'
In a stmt of a 'do' block: putStrLn "You typed: " ++ userInput
Main.hs:16:41:
Couldn't match type `[]' with `IO'
Expected type: IO Char
Actual type: [Char]
In a stmt of a 'do' block: putStrLn "You typed: " ++ userInput
In the expression:
do { putStrLn "You typed: " ++ userInput;
gameloop (world {loopCount = loopCount world + 1}) }
In a case alternative:
_ -> do { putStrLn "You typed: " ++ userInput;
gameloop (world {loopCount = loopCount world + 1}) }
Main.hs:19:28:
Couldn't match expected type `IO b0' with actual type `World'
In the expression: world
In a case alternative: Stopped -> world
In the expression:
case gameState world of {
Running
-> do { userInput <- getLine;
case userInput of {
"pause" -> ...
"stop" -> ...
_ -> ... } }
Paused -> gameloop world
Stopped -> world }
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
putStrLn "You typed: " ++ userInput
gameloop world { loopCount = loopCount world + 1 }
Paused -> gameloop world
Stopped -> 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