[Haskell-cafe] State & nested structures

Christopher Done chrisdone at googlemail.com
Fri Oct 29 10:35:35 EDT 2010


2010/10/29 Dupont Corentin <corentin.dupont at gmail.com>:
> 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!"

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

You can have a class that expresses the operations upon some B, e.g.

class MonadB m where
   getB :: m b

and then implement that class for both SA and SB. Or you can implement
MonadTrans in order to write the more generic function SB x ->  SA x.
Possibly both but preferably the former imho.


More information about the Haskell-Cafe mailing list