
David Menendez wrote:
wren ng thornton wrote:
Heinrich Apfelmus wrote:
In particular, it's not possible to implement
lift :: (Monad m, MonadTrans t) => m a -> t m a
Why not? * morph says m(t m a) is a subset of (t m a) * Monad m says we can fmap :: (a->b) -> (m a->m b) * Monad (t m) says we can return :: a -> t m a
lift ma = morph (\k -> k (fmap return ma))
Maybe something like this?
lift m = morph (\k -> m >>= k . return) -- n.b., return and >>= are from different monads
Nice! And it's consistent with the proposed equation morph (\down -> m >>= h down) = lift m >>= morph . flip h which says that effects that happen before applying down can be lifted out of morph . Regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com