[Haskell-cafe] Simple game: a monad for each player

Yves Parès limestrael at gmail.com
Sat Apr 10 16:59:48 EDT 2010

Okay for IA, which doesn't need any special monad, but what if I want to make
a network player ?
It would have to run in a State monad, accessing to IO, storing a
For instance, (Monad m) => StateT ByteString m.
The ByteString is a lazy one, we read from it to get the data sent by the
real player through the network.

Then, if I want to have a human an a network player playing sequentially,
how can I do this without stacking each player's monad? (See my first mail)

Philippa Cowderoy wrote:
> On 10/04/2010 13:57, Yves Parès wrote:
>> I answered my own question by reading this monad-prompt example:
>> http://paste.lisp.org/display/53766
>> But one issue remains: those examples show how to make play EITHER a
>> human
>> or an AI. I don't see how to make a human player and an AI play
>> (to a TicTacToe, for instance).
> Make them polymorphic - the human player in any MonadIO, the AI player 
> in any monad. Then run them both in the same monad, with some kind of 
> wrapping function around the calls setting a context for the appropriate 
> player.
> -- 
> flippa at flippac.org
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

Yves Parès

Live long and prosper
View this message in context: http://old.nabble.com/Simple-game%3A-a-monad-for-each-player-tp28183930p28204685.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

More information about the Haskell-Cafe mailing list