Created
November 29, 2012 20:31
-
-
Save aardvarrk/4171711 to your computer and use it in GitHub Desktop.
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
| class FunctorIO f where | |
| fmapIO :: f a -> IO (f b) | |
| data Input = Input Time Random Keyboard Mouse Joystick | |
| data State = State {shizzle} | |
| data Output = Output | |
| data Game a = Game State a | |
| instance FunctorIO Game where | |
| fmapIO :: Game (Maybe Input) -> IO (Game Output) | |
| fmapIO (Game state input) = do | |
| newState <- updateGame state input | |
| return $ Game newState Output | |
| main :: IO () | |
| main = loop $ Game initialState Nothing | |
| where | |
| loop (Game state _) = do | |
| maybeInput <- getInput | |
| newGame <- fmapIO $ Game state maybeInput | |
| loop newGame |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment