Suppose I have the following class of monad transformers: 

class (Monad m, Monad (t m)) => MonadT t m where
 lift :: m a -> t m a

and several instances of the class:

instance MonadT MT1 where ...
instance MonadT MT2 where ...
. . .
instance MonadT MTn where ...

I obtain a new monad composing monad transformers through the IO monad:

type MyMonad = MT1 (MT2 (... (MTn IO)))

And now, if I want to lift "putStrLn" I must write:

myPutStrLn = lift . lift . ... lift . putStrLn

This works but looks ugly. 

The question is:
Is there a way that the system could detect how many 
lifts are necessary to select the right function?

Another problem is when some of the monad transformers provide the same 
functions, for example, if MTi also provides "putStrLn", How could I tell 
the system to select the first "putStrLn" found, or the last?

Thanks, Jose Labra



Reply via email to