Portability | non-portable (rank-2 polymorphism) |
---|---|

Stability | experimental |

Maintainer | Edward Kmett <ekmett@gmail.com> |

The density comonad for a functor. aka the comonad cogenerated by a functor The ''density'' term dates back to Dubuc''s 1974 thesis. The term ''monad genererated by a functor'' dates back to 1972 in Street''s ''Formal Theory of Monads''.

- data Density k a = forall b . Density (k b -> a) (k b)
- densityToLan :: Density k a -> Lan k k a
- lanToDensity :: Lan k k a -> Density k a
- toDensity :: Functor s => (forall a. k a -> s (k a)) -> Density k :~> s
- fromDensity :: (Density k :~> s) -> k a -> s (k a)
- liftDensity :: Comonad w => w a -> Density w a
- lowerDensity :: Comonad w => Density w a -> w a
- densityToAdjunction :: Adjunction f g => Density f a -> f (g a)
- adjunctionToDensity :: Adjunction f g => f (g a) -> Density f a
- densityToComposedAdjunction :: (Composition o, Adjunction f g) => Density f :~> (f `o` g)
- composedAdjunctionToDensity :: (Composition o, Adjunction f g) => (f `o` g) :~> Density f
- improveCofree :: Functor f => (forall w. ComonadCofree f w => w a) -> Cofree f a

# Documentation

forall b . Density (k b -> a) (k b) |

ComonadTrans Density | |

ComonadContext e w => ComonadContext e (Density w) | |

ComonadReader e w => ComonadReader e (Density w) | |

RunComonadCofree f w => RunComonadCofree f (Density w) | |

ComonadCofree f w => ComonadCofree f (Density w) | |

Functor (Density f) | |

Copointed (Density f) | |

Comonad (Density f) |

densityToLan :: Density k a -> Lan k k aSource

lanToDensity :: Lan k k a -> Density k aSource

toDensity :: Functor s => (forall a. k a -> s (k a)) -> Density k :~> sSource

`Nat(k, s.k)`

is isomorphic to `Nat (Density k, s)`

(forwards)

fromDensity :: (Density k :~> s) -> k a -> s (k a)Source

`Nat(k, s.k)`

is isomorphic to `Nat (Density k, s)`

(backwards)

liftDensity :: Comonad w => w a -> Density w aSource

The natural isomorphism between a comonad w and the comonad generated by w (forwards).

lowerDensity :: Comonad w => Density w a -> w aSource

The natural isomorphism between a comonad w and the comonad generated by w (backwards).

densityToAdjunction :: Adjunction f g => Density f a -> f (g a)Source

adjunctionToDensity :: Adjunction f g => f (g a) -> Density f aSource

densityToComposedAdjunction :: (Composition o, Adjunction f g) => Density f :~> (f `o` g)Source

composedAdjunctionToDensity :: (Composition o, Adjunction f g) => (f `o` g) :~> Density fSource

improveCofree :: Functor f => (forall w. ComonadCofree f w => w a) -> Cofree f aSource