Sun Aug 23 16:44:47 EDT 2015

Monads and bad intuitions

I had the false impression that it is not possible to lift anything
out of a monad type constructor, but it *is* possible to lift (i->)
back out, i.e. turn a lifted Kleisli arrow back into normal form:

unlift1 :: Monad m => m (a -> m b) -> a -> m b
unlift1 mf a = do f <- mf; f a

unlift2 :: Monad m => (m a -> m b) -> a -> m b
unlift2 f = f . return

The reason is that as long as there is one layer of wrapping, it's
always possible to +1 or -1 with return and join.