KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to write a Spider Solitaire player as a Haskell learning exercise. My main function will call a playGame function once for each game (using mapM ), passing in the game number and a random generator ( StdGen ). The playGame function should return a Control.Monad.State monad and an IO monad that contains a String showing the game tableau and a Bool indicating if the game was won or lost. How do I combine the State monad with the IO monad for the return value? What should the type declaration for `playGame be? playGame :: Int -> StdGen a -> State IO (String, Bool) Is the State IO (String, Bool) correct? If not, what should it be? In main , I plan on using do -- get the number of games from the command line (already written) results <- mapM (\game -> playGame game getStdGen) [1..numberOfGames] Is this the correct way to call playGame ?
Tags (comma-separated)
Save Edits
Cancel