[Haskell-beginners] IO Control Structures

Leonhard Applis Leonhard.Applis at protonmail.com
Tue Apr 23 14:55:22 UTC 2019


Hey there,

I am writing a simple game and the only missing part is IO (Sadly, i need that to play).

I've got most things pure, e.g. makeMove :: GameState -> Move -> GameState, initialBoard:: GameState and lost :: GameState -> Bool work pure and as intended.
I also got a function gameLoop :: GameState -> IO GameState which asks for Input and applies it.

I don`t know how to do my main :: IO ()
which should welcome the player, start the gameloop, and print godbyes the game if it's either won or lost
Here i am missing a control structure, to demonstrate:

show hello
board = initialBoard
while (not end board)
    board = gameLoop board
show winner

I could also make my Gameloop recursive, while i think that i get this working, it seems awfully complex (and ugly) to me.

Best regards
Leonhard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20190423/0256a91e/attachment.html>


More information about the Beginners mailing list