Skip to content

Instantly share code, notes, and snippets.

@LindseyB
Created September 18, 2010 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LindseyB/586098 to your computer and use it in GitHub Desktop.
Save LindseyB/586098 to your computer and use it in GitHub Desktop.
type World = String
type Player = String
initWorld :: IO World
initWorld = return "World"
initPlayer :: IO Player
initPlayer = return "Player"
act :: World -> String -> World
act w i = w
hasWon :: World -> Bool
hasWon w = True
getInput :: IO String
getInput = getLine
gameLoop :: Int -> World -> Player -> IO World
gameLoop n w p
| hasWon w == (n == 10) = return w
| otherwise = do
i <- getInput
putStrLn ("Hey " ++ show n ++ " " ++ i)
hFlush
gameLoop (n + 1) (act w i) p
main = do
world <- initWorld
player <- initPlayer
gameLoop 0 world player
putStr "Goodbye!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment