2010/10/29 Dupont Corentin <corentin.dup...@gmail.com>:

> Also, I can't manage to write the more generic function SB x ->  SA x.
>

Horribly enough this one seems to work...

mapOnBofA :: SB a -> SA a
mapOnBofA mf = get >>= \st@(A {b=temp}) ->
               let (ans,temp2) = runState mf temp
               in put (st { b=temp2}) >> return ans

However, I'd have to question why you want both SA and SB as state
functional types. Having inner runState's is sometimes good practice
(its an instance of the Local Effect pattern identified by Ralf
Laemmel and Joost Visser), but if you have it "commonly" I'd suspect
you design is somehow contrived and could be simplified.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to