
29 Oct
2010
29 Oct
'10
11:35 a.m.
2010/10/29 Dupont Corentin
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.