<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"><<a href="mailto:steffen.siering@googlemail.com">steffen.siering@googlemail.com</a>></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>> Horribly enough this one seems to work...<br>><br>> mapOnBofA :: SB a -> SA a<br>> mapOnBofA mf = get >>= \st@(A {b=temp}) -><br>> let (ans,temp2) = runState mf temp<br>
> in put (st { b=temp2}) >> return ans<br>><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's.<br><br>@Dupont:<br>telling from your possible use case and your last post with your "MAP"-<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 <<a href="mailto:stephen.tet...@gmail.com">stephen.tet...@gmail.com</a>> wrote:<br>
> 2010/10/29 Dupont Corentin <<a href="mailto:corentin.dup...@gmail.com">corentin.dup...@gmail.com</a>>:<br>
<div class="im">><br>> > Also, I can't manage to write the more generic function SB x -> SA x.<br>><br></div>
<div class="im">> However, I'd have to question why you want both SA and SB as state<br>> functional types. Having inner runState's is sometimes good practice<br>> (its an instance of the Local Effect pattern identified by Ralf<br>
> Laemmel and Joost Visser), but if you have it "commonly" I'd suspect<br>> you design is somehow contrived and could be simplified.<br>> _______________________________________________<br>> Haskell-Cafe mailing list<br>
</div>> 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>