# Pastebin ljFJ4GK1 import Control.Monad.Except import Control.Monad.Cont -- liftEither is available in mtl >=2.2.2 one :: Either e a -> ExceptT e (ContT r IO) a one = liftEither two :: Either e a -> ExceptT e (ContT r IO) a two = _ -- GHC asks for: `Either e a -> ExceptT e (ContT r IO) a` two e = _ -- Name the parameter; GHC asks for: `ExceptT e (ContT r IO) a` two e = ExceptT _ -- Introduce `ExceptT` constructor; GHC asks for: `(ContT r IO) (Either e a)` two e = ExceptT $ ContT _ -- Introduce `ContT` constructor; GHC asks for: (Either e a -> IO r) -> IO r two e = ExceptT $ ContT $ \k -> _ -- GHC asked for a function, so introduce lambda; GHC now asks for: `IO r` two e = ExceptT $ ContT $ \k -> k _ -- The only thing that returns `IO r` is `k`; GHC now asks for: `Either e a` two e = ExceptT $ ContT $ \k -> k e -- `e` is the only value of type `Either e a` available to us