<div>Thank you for your responses. I will look at monad transformers.</div>
<div>I already use them I think because actually I use something like StateT Game IO a.</div>
<div>You mean I have to implement my own instance?</div>
<div> </div>
<div>Oh, can you call me Corentin? This is my name ;) </div>
<div> </div>
<div>Cheers,</div>
<div>Corentin<br><br></div>
<div class="gmail_quote">On Fri, Oct 29, 2010 at 6:19 PM, steffen <span dir="ltr">&lt;<a href="mailto:steffen.siering@googlemail.com">steffen.siering@googlemail.com</a>&gt;</span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div class="im"><br>&gt; Horribly enough this one seems to work...<br>&gt;<br>&gt; mapOnBofA :: SB a -&gt; SA a<br>&gt; mapOnBofA mf = get &gt;&gt;= \st@(A {b=temp}) -&gt;<br>&gt;                let (ans,temp2) = runState mf temp<br>
&gt;                in put (st { b=temp2}) &gt;&gt; return ans<br>&gt;<br><br></div>There is nothing horrible about that. You just run a new isolated<br>computation in the State Monad for B and use its results. More or less<br>
see same solution as Dupont&#39;s.<br><br>@Dupont:<br>telling from your possible use case and your last post with your &quot;MAP&quot;-<br>Problem, these two are very similar. You have a monad and inside your<br>monad you temporarily want to run some computation in another Monad. I<br>
think Monad-Transformers are maybe the better option for you<br>(especially your interpreter-Problem was a good use case for StateT/<br>ErrorT instead of State and some Either inside it...).<br><br>On 29 Okt., 17:35, Stephen Tetley &lt;<a href="mailto:stephen.tet...@gmail.com">stephen.tet...@gmail.com</a>&gt; wrote:<br>
&gt; 2010/10/29 Dupont Corentin &lt;<a href="mailto:corentin.dup...@gmail.com">corentin.dup...@gmail.com</a>&gt;:<br>
<div class="im">&gt;<br>&gt; &gt; Also, I can&#39;t manage to write the more generic function SB x -&gt;  SA x.<br>&gt;<br></div>
<div class="im">&gt; However, I&#39;d have to question why you want both SA and SB as state<br>&gt; functional types. Having inner runState&#39;s is sometimes good practice<br>&gt; (its an instance of the Local Effect pattern identified by Ralf<br>
&gt; Laemmel and Joost Visser), but if you have it &quot;commonly&quot; I&#39;d suspect<br>&gt; you design is somehow contrived and could be simplified.<br>&gt; _______________________________________________<br>&gt; Haskell-Cafe mailing list<br>
</div>&gt; Haskell-C...@haskell.orghttp://<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<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>