I&#39;m trying to build a list where each entry depends on the previous one.  Unfoldr seemed like a good idea at the time.<br>Unfortunately, my values are monadic values (specifically RVars, from the random-fu package).  Okay, shouldn&#39;t be a problem; I just monadic bind and...<br>
<br>&gt; -- example code<br>&gt; updateCell :: Bool -&gt; RVar Bool<br>&gt; updateCell False = return False<br>&gt; updateCell True  = bernoulli (0.9 :: Double)<br><br>&gt; sim = sequence $ take 20 $ unfoldr (\x -&gt; Just (x, x &gt;&gt;= updateCell)) (return True)<br>
<br>&gt; runRVar sim DevURandom<br clear="all">[True,True,True,True,True,False,True,False,True,False,False,False,False,False,False,True,True,False,False,False]<br><br>That output shouldn&#39;t be possible if I&#39;m doing things right...  It appears that each cell has an independent history.  I&#39;m stumped.<br>
Advice on threading monad input in general and random-fu in specific would be appreciated.<br><br>-- <br><div dir="ltr"><div>          Alex R</div></div><br>