kan-extensions-4.2.2: Kan extensions, Kan lifts, various forms of the Yoneda lemma, and (co)density (co)monads

Copyright (C) 2011 Edward Kmett BSD-style (see the file LICENSE) Edward Kmett provisional non-portable (rank-2 polymorphism) Trustworthy Haskell98

Description

Co can be viewed as a right Kan lift along a Comonad.

For any r, the Contravariant functor / presheaf (-> r) :: Hask^op -> Hask is adjoint to the "same" Contravariant functor (-> r) :: Hask -> Hask^op. So we can sandwhich a Monad in Hask^op in the middle to obtain w (a -> r-) -> r+, and then take a coend over r to obtain forall r. w (a -> r) -> r. This gives rise to Co. If we observe that we didn't care what the choices we made for r were to finish this construction, we can upgrade to forall r. w (a -> m r) -> m r in a manner similar to how ContT is constructed yielding CoT.

We could consider unifying the definition of Co and Rift, but there are many other arguments for which Rift can form a Monad, and this wouldn't give rise to CoT.

Synopsis

type Co w = CoT w Identity Source

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

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

newtype CoT w m a Source

Co w a ~ Rift w Identity a

Constructors

 CoT FieldsrunCoT :: forall r. w (a -> m r) -> m r

Instances

# Klesili from CoKleisli

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

liftCoT0M :: (Comonad w, Monad m) => (forall a. w a -> m s) -> CoT w m s Source

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

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

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

liftCoT1M :: Monad m => (forall a. w a -> m a) -> CoT w m () Source

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

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

diter :: Functor f => a -> (a -> f a) -> Density (Cofree f) a Source

dctrlM :: (Comonad w, Monad m) => (forall a. w a -> m (w a)) -> CoT (Density w) m () Source

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

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

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