Closed georgevarghese185 closed 6 years ago
Like this?
lift2 :: forall m a t t'.
MonadTrans t =>
MonadTrans t' =>
Monad m =>
Monad (t m) =>
m a ->
t' (t m) a
lift2 = lift <<< lift
Might be worth using a slightly different name to avoid clashing with the Applicative liftn
functions.
Oh that's true. What about liftT2, liftT3 ? But now it seems different from lift
which doesn't have a T in it.
Yes, that's a good point. Maybe it would be best to call them lift2
, lift3
, etc, and let people import Control.Monad.Trans.Class
qualified and use them like Trans.lift2
or something.
I don't have an opinion for or against adding these functions, though.
I would say that the need for these functions is probably fairly uncommon, as the MonadState
, etc. classes will lift through as many layers as necessary.
Good point. Shall we close this, then?
Would it make sense to add some helper functions to do multiple lifts in a row? I find myself doing 2 or 3 lifts in quite a few places where I have stacks of Monad Transformers and it would be nice if some already defined
liftn
functions existed...