Haha, not exactly.<br><br>You can replace<br><br>sj &lt;- get<br>let (a, sk) = runState something sj<br>put sk<br><br>with<br><br>a &lt;- something<br><br>Also, you don&#39;t need do notation for single statements; &quot;do return x&quot; is just &quot;return x&quot;<br>
<br><br><div class="gmail_quote">On Wed, Dec 22, 2010 at 7:21 PM, michael rice <span dir="ltr">&lt;<a href="mailto:nowgate@yahoo.com">nowgate@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font: inherit;" valign="top">Thanks for the tip, Ozgur. It worked for me. Is this what you had in mind, Ryan?<br><br>Michael<br><br>==============<br>
<br>import Control.Monad.State.Lazy<div class="im"><br>import Control.Monad<br>import System.Random<br><br>type GeneratorState = State StdGen<br></div><div class="im">data Craps a = Roll a | Win a | Lose a deriving (Show)<br>
<br></div><div class="im">genRandomR :: Random a =&gt; (a,a) -&gt; GeneratorState a<br>genRandomR = state . randomR<br><br>rollDie :: GeneratorState Int<br>rollDie = genRandomR (1,6)<br><br>roll2Dice :: GeneratorState Int<br>
roll2Dice = liftM2 (+) rollDie rollDie<br><br></div><div class="im">f :: Craps [Int] -&gt; GeneratorState (Craps [Int])<br>f (Roll []) = do g0 &lt;- get<br></div>                 let (throw1,g1) = runState roll2Dice
 g0<br>                 put g1<br>                 case throw1 of<br>                    2 -&gt; return (Lose [throw1])<br>                    3 -&gt; return (Lose [throw1])<br>                    7 -&gt; return (Win [throw1])<br>
                    11 -&gt; return (Win [throw1])<br>                    _ -&gt; do g1 &lt;-
 get<br>                            let (throw2,g2) = runState roll2Dice g1<br>                            put g2<br>                            if throw2 == throw1<br>                              then do return (Win [throw1,throw2])<br>
                             
 else<br>                                if throw2 == 7<br>                                  then do return (Lose [throw1,throw2])<br>                                  else do f (Roll [throw1,throw2])<br>f (Roll z@(throw1:throws)) = do g0 &lt;- get<br>
                                let (throw,g1) = runState roll2Dice
 g0<br>                                put g1<br>                                if throw == throw1<br>                                  then do return (Win (z ++ [throw]))<br>                                 
 else<br>                                    if throw == 7<br>                                      then do return (Lose (z ++ [throw]))<br>                                      else do f (Roll (z ++ [throw]))<br><br><br>
<br>--- On <b>Wed, 12/22/10, Ozgur Akgun <i>&lt;<a href="mailto:ozgurakgun@gmail.com" target="_blank">ozgurakgun@gmail.com</a>&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">
<br>From:
 Ozgur Akgun &lt;<a href="mailto:ozgurakgun@gmail.com" target="_blank">ozgurakgun@gmail.com</a>&gt;<div class="im"><br>Subject: Re: [Haskell-cafe] Why is Haskell flagging this?<br></div>To: &quot;Ryan Ingram&quot; &lt;<a href="mailto:ryani.spam@gmail.com" target="_blank">ryani.spam@gmail.com</a>&gt;<br>
Cc: <a href="mailto:haskell-cafe@haskell.org" target="_blank">haskell-cafe@haskell.org</a>, &quot;Daniel Fischer&quot; &lt;<a href="mailto:daniel.is.fischer@googlemail.com" target="_blank">daniel.is.fischer@googlemail.com</a>&gt;<br>
Date: Wednesday, December 22, 2010, 7:37 PM<div><div></div><div class="h5"><br><br><div>see also: <a rel="nofollow" href="http://hackage.haskell.org/packages/archive/mtl/latest/doc/html/Control-Monad-State-Lazy.html#v:state" target="_blank">http://hackage.haskell.org/packages/archive/mtl/latest/doc/html/Control-Monad-State-Lazy.html#v:state</a><br>

<br><div>On 22 December 2010 20:02, Ryan Ingram <span dir="ltr">&lt;<a rel="nofollow" href="http://mc/compose?to=ryani.spam@gmail.com" target="_blank">ryani.spam@gmail.com</a>&gt;</span> wrote:<br><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div>Interesting.  In that case,<br>
<br>
state f = StateT $ \s -&gt; Identity (f s)<br>
<br>
allows &quot;state&quot; to replace &quot;State&quot; in that code.</div></blockquote></div><br clear="all">Ozgur
</div><br></div></div>-----Inline Attachment Follows-----<div class="im"><br><br><div>_______________________________________________<br>Haskell-Cafe mailing list<br><a href="http://mc/compose?to=Haskell-Cafe@haskell.org" target="_blank">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></td></tr></tbody></table><br>

      </blockquote></div><br>