Last active
December 20, 2015 16:59
-
-
Save joseph-montanez/6165459 to your computer and use it in GitHub Desktop.
main cannot determine the type of gameloop?
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
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' |
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 -> (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