Okay, I start to understand better...<br><br>Just, Heinrich, how would implement the mapMonad function in terms of the operational package?<br>You just shown the signature.<br><br><div class="gmail_quote">2010/4/14 Bertram Felgenhauer <span dir="ltr"><<a href="mailto:bertram.felgenhauer@googlemail.com">bertram.felgenhauer@googlemail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">Limestraėl wrote:<br>
> Okay, I just understood that 'Prompt' was just a sort of view for 'Program'.<br>
<br>
</div>Right.<br>
<div class="im"><br>
> > runMyStackT :: MyStackT (Player m) a -> Player m a<br>
><br>
> According to what Bertram said, "each strategy can pile its own custom monad<br>
> stack ON the (Player m) monad".<br>
<br>
</div>Yes, and I meant what Heinrich wrote, you wrap some transformer around<br>
the common Player m monad.<br>
<div class="im"><br>
> > game :: Monad m => Player m () -> Player m () -> m ()<br>
> As it is written, it requires both players to run in the SAME monad.<br>
> And if have a network player ( e.g.* Player (StateT Handle IO)* ) and an AI<br>
> storing former opponent's moves ( e.g. *(Monad m) => Player (StateT [Move]<br>
> m)* ), then they can't be in the same monad...<br>
<br>
</div>The idea is to pick m = IO, and then use<br>
<br>
type NetPlayer a = StateT Handle (Player IO) a<br>
<br>
and<br>
<br>
type AIPlayer a = StateT [Move] (Player IO) a<br>
<br>
or possibly<br>
<br>
type AIPlayer a = StateT [Move] (Player Identity) a<br>
<br>
using the mapPlayerM (or mapMonad as suggested by Heinrich) function.<br>
<br>
You'd then provide functions like<br>
<br>
runAIPlayer :: AIPlayer a -> Player IO a<br>
runAIPlayer player = {- mapMonad (return . runIdentity) $ -}<br>
evalStateT player []<br>
<br>
This gives you most of what you want: You can add custom state and the<br>
like to each player. You can not hope to exchange the base monad m,<br>
because then the 'game' function would have to know how to run both<br>
of those base monads simultaneously. A function like mapMonad is the<br>
best device you can hope for, I think.<br>
<br>
regards,<br>
<font color="#888888"><br>
Bertram<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br>