13
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?