The Cont adjunction
May. 11th, 2020 10:04 pmhttps://gist.github.com/Lysxia/beb6f9df9777bbf56fe5b42de04e6c64
newtype (<-:) a b = Co { unCo :: b -> a } -- The composition of adjoint functors is a monad or a comonad (depending on which way it goes) newtype Compose f g a = Compose { unCompose :: f (g a) } -- The continuation monad as an adjunction: type Cont r = Compose ((<-:) r) ((<-:) r) runCont :: Cont r r -> r runCont (Compose (Co f)) = f (Co id)