
Hello the list, I have another silly question. In my software I have a very common pattern: --in file A.hs module A where data A = A {b :: B, i :: Int} type SA x = State A x -- many functions with SA x --in file B.hs data B = B {r :: Int} type SB x = State B x -- many functions with SB x Of course in module A I'm calling some functions of module B. I'd like to know if it's possible, in a function of type SA, to call a function of type SB, without actually executing the State SB. I just wanna tell him "Hey look, you can construct a SA from a SB like this!" For now I have this: bToA:: (B -> B) -> A -> A bToA bb = (λa -> a{b = bb (b a)}) useB :: SB () -> SA () useB = modify . bToA . execState Can I get rid of the execState? Also, I can't manage to write the more generic function SB x -> SA x. Cheers, Corentin