Skip to content

Instantly share code, notes, and snippets.

@joseph-montanez
Last active December 20, 2015 16:59
Show Gist options
  • Save joseph-montanez/6165459 to your computer and use it in GitHub Desktop.
Save joseph-montanez/6165459 to your computer and use it in GitHub Desktop.
main cannot determine the type of gameloop?
recur.hs:15:1: Couldn't match expected type `IO t0' with actual type `World' In the expression: main When checking the type of the function `main'
data GameState = Running | Paused | Stopped
data World = World {
gameState :: GameState,
loopCount :: Int
}
gameloop :: World -> (World)
gameloop world =
case gameState world of
Running -> gameloop world { loopCount = loopCount world + 1 }
Paused -> gameloop world
Stopped -> world
main = gameloop $ World Running 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment