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

Copyright | (C) 2008-2016 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | experimental
Portability | non-portable (GADTs, MPTCs)
Safe Haskell | Safe-Inferred
Language | Haskell2010

Control.Comonad.Density

Description

The `Density` `Comonad` for a `Functor` (aka the 'Comonad generated by a `Functor`) The `Density` term dates back to Dubuc''s 1974 thesis. The term `Monad` generated by a `Functor` dates back to 1972 in Street''s ''Formal Theory of Monads''.

The left Kan extension of a `Functor` along itself (``Lan` f f`) forms a `Comonad`. This is that `Comonad`.

Synopsis

- data Density (k1 :: k -> Type) a where
  - Density :: forall {k} (k1 :: k -> Type) (b :: k) a. (k1 b -> a) -> k1 b -> Density k1 a
- liftDensity :: Comonad w => w a -> Density w a
- densityToAdjunction :: Adjunction f g => Density f a -> f (g a)
- adjunctionToDensity :: Adjunction f g => f (g a) -> Density f a
- densityToLan :: forall {k} (f :: k -> Type) a. Density f a -> Lan f f a
- lanToDensity :: forall {k} (f :: k -> Type) a. Lan f f a -> Density f a

# Documentation

data Density (k1 :: k -> Type) a where Source #

Constructors

Density :: forall {k} (k1 :: k -> Type) (b :: k) a. (k1 b -> a) -> k1 b -> Density k1 a |

#### Instances

Instances details

ComonadTrans (Density :: (Type -> Type) -> Type -> Type) Source # |
Instance details Defined in Control.Comonad.Density Methods lower :: Comonad w => Density w a -> w a Source #
Comonad (Density f) Source # |
Instance details Defined in Control.Comonad.Density Methods extract :: Density f a -> a Source # duplicate :: Density f a -> Density f (Density f a) Source # extend :: (Density f a -> b) -> Density f a -> Density f b Source #
Applicative f => Applicative (Density f) Source # |
Instance details Defined in Control.Comonad.Density Methods pure :: a -> Density f a Source # (<*>) :: Density f (a -> b) -> Density f a -> Density f b Source # liftA2 :: (a -> b -> c) -> Density f a -> Density f b -> Density f c Source # (*>) :: Density f a -> Density f b -> Density f b Source # (<*) :: Density f a -> Density f b -> Density f a Source #
Functor (Density f) Source # |
Instance details Defined in Control.Comonad.Density Methods fmap :: (a -> b) -> Density f a -> Density f b Source # (<$) :: a -> Density f b -> Density f a Source #
Apply f => Apply (Density f) Source # |
Instance details Defined in Control.Comonad.Density Methods (<.>) :: Density f (a -> b) -> Density f a -> Density f b Source # (.>) :: Density f a -> Density f b -> Density f b Source # (<.) :: Density f a -> Density f b -> Density f a Source # liftF2 :: (a -> b -> c) -> Density f a -> Density f b -> Density f c Source #
Extend (Density f) Source # |
Instance details Defined in Control.Comonad.Density Methods duplicated :: Density f a -> Density f (Density f a) Source # extended :: (Density f a -> b) -> Density f a -> Density f b Source #

liftDensity :: Comonad w => w a -> Density w a Source #

The natural transformation from a ``Comonad` w` to the `Comonad` generated by `w` (forwards).

This is merely a right-inverse (section) of `lower`, rather than a full inverse.

    lower . liftDensity ≡ id

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

The Density `Comonad` of a left adjoint is isomorphic to the `Comonad` formed by that `Adjunction`.

This isomorphism is witnessed by `densityToAdjunction` and `adjunctionToDensity`.

    densityToAdjunction . adjunctionToDensity ≡ id
    adjunctionToDensity . densityToAdjunction ≡ id

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

densityToLan :: forall {k} (f :: k -> Type) a. Density f a -> Lan f f a Source #

lanToDensity :: forall {k} (f :: k -> Type) a. Lan f f a -> Density f a Source #

The `Density` `Comonad` of a `Functor` `f` is obtained by taking the left Kan extension (`Lan`) of `f` along itself. This isomorphism is witnessed by `lanToDensity` and `densityToLan`

    lanToDensity . densityToLan ≡ id
    densityToLan . lanToDensity ≡ id