kan-extensions-3.4: Kan extensions, Kan lifts, the Yoneda lemma, and (co)density (co)monads

Portabilitynon-portable (rank-2 polymorphism)
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellTrustworthy




Monads from Comonads


Co and CoT just special cases of the general notion of a Right Kan lift.

TODO: We could consider unifying the definition of CoT and Rift, but Rift f f also forms a Codensity-like Monad, so there is a reasonable case for keeping them separate.


Monads from Comonads

type Co w = CoT w IdentitySource

co :: Functor w => (forall r. w (a -> r) -> r) -> Co w aSource

runCo :: Functor w => Co w a -> w (a -> r) -> rSource

Monad Transformers from Comonads

newtype CoT w m a Source

 CoT w m a ~ Rift w m a
 Co w a ~ Rift w Identity a




runCoT :: forall r. w (a -> m r) -> m r


(Comonad w, MonadError e m) => MonadError e (CoT w m) 
(Comonad w, MonadReader e m) => MonadReader e (CoT w m) 
(Comonad w, MonadState s m) => MonadState s (CoT w m) 
(Comonad w, MonadWriter e m) => MonadWriter e (CoT w m) 
Comonad w => MonadTrans (CoT w) 
Comonad w => Monad (CoT w m) 
Functor w => Functor (CoT w m) 
Comonad w => Applicative (CoT w m) 
(Comonad w, MonadIO m) => MonadIO (CoT w m) 
Extend w => Apply (CoT w m) 
Extend w => Bind (CoT w m) 
Comonad w => MonadSpec (CoT w m) 

Klesili from CoKleisli

liftCoT0 :: Comonad w => (forall a. w a -> s) -> CoT w m sSource

lowerCoT0 :: (Functor w, Monad m) => CoT w m s -> w a -> m sSource

lowerCo0 :: Functor w => Co w s -> w a -> sSource

liftCoT1 :: (forall a. w a -> a) -> CoT w m ()Source

lowerCoT1 :: (Functor w, Monad m) => CoT w m () -> w a -> m aSource

lowerCo1 :: Functor w => Co w () -> w a -> aSource

posW :: (ComonadStore s w, Monad m) => CoT w m sSource

peekW :: (ComonadStore s w, Monad m) => s -> CoT w m ()Source

peeksW :: (ComonadStore s w, Monad m) => (s -> s) -> CoT w m ()Source

askW :: (ComonadEnv e w, Monad m) => CoT w m eSource

asksW :: (ComonadEnv e w, Monad m) => (e -> a) -> CoT w m aSource

traceW :: (ComonadTraced e w, Monad m) => e -> CoT w m ()Source