kan-extensions-5.2.5: Kan extensions, Kan lifts, the Yoneda lemma, and (co)density (co)monads
Copyright (C) 2011-2016 Edward Kmett
License BSD-style (see the file LICENSE)
Maintainer Edward Kmett <ekmett@gmail.com>
Stability provisional
Portability GADTs, MPTCs, fundeps
Safe Haskell Trustworthy
Language Haskell2010

Data.Functor.Coyoneda

Description

Coyoneda f is the "free functor" over f . The co-Yoneda lemma for a covariant Functor f states that Coyoneda f is naturally isomorphic to f .

Synopsis

Documentation

data Coyoneda f a where Source #

A covariant Functor suitable for Yoneda reduction

Constructors

Coyoneda :: (b -> a) -> f b -> Coyoneda f a

Instances

Instances details
ComonadTrans Coyoneda Source #
Instance details

Defined in Data.Functor.Coyoneda

MonadTrans Coyoneda Source #
Instance details

Defined in Data.Functor.Coyoneda

Methods

lift :: Monad m => m a -> Coyoneda m a Source #

Monad m => Monad ( Coyoneda m) Source #
Instance details

Defined in Data.Functor.Coyoneda

Functor ( Coyoneda f) Source #
Instance details

Defined in Data.Functor.Coyoneda

MonadFix f => MonadFix ( Coyoneda f) Source #
Instance details

Defined in Data.Functor.Coyoneda

Methods

mfix :: (a -> Coyoneda f a) -> Coyoneda f a Source #

Applicative f => Applicative ( Coyoneda f) Source #
Instance details

Defined in Data.Functor.Coyoneda

Foldable f => Foldable ( Coyoneda f) Source #
Instance details

Defined in Data.Functor.Coyoneda

Traversable f => Traversable ( Coyoneda f) Source #
Instance details

Defined in Data.Functor.Coyoneda

Distributive f => Distributive ( Coyoneda f) Source #
Instance details

Defined in Data.Functor.Coyoneda

Representable f => Representable ( Coyoneda f) Source #
Instance details

Defined in Data.Functor.Coyoneda

Associated Types

type Rep ( Coyoneda f) Source #

Eq1 f => Eq1 ( Coyoneda f) Source #
Instance details

Defined in Data.Functor.Coyoneda

Methods

liftEq :: (a -> b -> Bool ) -> Coyoneda f a -> Coyoneda f b -> Bool Source #

Ord1 f => Ord1 ( Coyoneda f) Source #
Instance details

Defined in Data.Functor.Coyoneda

Read1 f => Read1 ( Coyoneda f) Source #
Instance details

Defined in Data.Functor.Coyoneda

( Functor f, Show1 f) => Show1 ( Coyoneda f) Source #
Instance details

Defined in Data.Functor.Coyoneda

Alternative f => Alternative ( Coyoneda f) Source #
Instance details

Defined in Data.Functor.Coyoneda

MonadPlus f => MonadPlus ( Coyoneda f) Source #
Instance details

Defined in Data.Functor.Coyoneda

Comonad w => Comonad ( Coyoneda w) Source #
Instance details

Defined in Data.Functor.Coyoneda

Plus f => Plus ( Coyoneda f) Source #
Instance details

Defined in Data.Functor.Coyoneda

Traversable1 f => Traversable1 ( Coyoneda f) Source #
Instance details

Defined in Data.Functor.Coyoneda

Methods

traverse1 :: Apply f0 => (a -> f0 b) -> Coyoneda f a -> f0 ( Coyoneda f b) Source #

sequence1 :: Apply f0 => Coyoneda f (f0 b) -> f0 ( Coyoneda f b) Source #

Alt f => Alt ( Coyoneda f) Source #
Instance details

Defined in Data.Functor.Coyoneda

Apply f => Apply ( Coyoneda f) Source #
Instance details

Defined in Data.Functor.Coyoneda

Bind m => Bind ( Coyoneda m) Source #
Instance details

Defined in Data.Functor.Coyoneda

Foldable1 f => Foldable1 ( Coyoneda f) Source #
Instance details

Defined in Data.Functor.Coyoneda

Extend w => Extend ( Coyoneda w) Source #
Instance details

Defined in Data.Functor.Coyoneda

Adjunction f g => Adjunction ( Coyoneda f) ( Coyoneda g) Source #
Instance details

Defined in Data.Functor.Coyoneda

( Eq1 f, Eq a) => Eq ( Coyoneda f a) Source #
Instance details

Defined in Data.Functor.Coyoneda

( Ord1 f, Ord a) => Ord ( Coyoneda f a) Source #
Instance details

Defined in Data.Functor.Coyoneda

Read (f a) => Read ( Coyoneda f a) Source #
Instance details

Defined in Data.Functor.Coyoneda

( Functor f, Show1 f, Show a) => Show ( Coyoneda f a) Source #
Instance details

Defined in Data.Functor.Coyoneda

type Rep ( Coyoneda f) Source #
Instance details

Defined in Data.Functor.Coyoneda

liftCoyoneda :: f a -> Coyoneda f a Source #

Yoneda "expansion"

liftCoyoneda . lowerCoyonedaid
lowerCoyoneda . liftCoyonedaid
lowerCoyoneda (liftCoyoneda fa) = -- by definition
lowerCoyoneda (Coyoneda id fa)  = -- by definition
fmap id fa                      = -- functor law
fa
lift = liftCoyoneda

lowerCoyoneda :: Functor f => Coyoneda f a -> f a Source #

Yoneda reduction lets us walk under the existential and apply fmap .

Mnemonically, "Yoneda reduction" sounds like and works a bit like β-reduction.

http://ncatlab.org/nlab/show/Yoneda+reduction

You can view Coyoneda as just the arguments to fmap tupled up.

lower = lowerM = lowerCoyoneda

lowerM :: Monad f => Coyoneda f a -> f a Source #

Yoneda reduction given a Monad lets us walk under the existential and apply liftM .

You can view Coyoneda as just the arguments to liftM tupled up.

lower = lowerM = lowerCoyoneda

hoistCoyoneda :: ( forall a. f a -> g a) -> Coyoneda f b -> Coyoneda g b Source #

Lift a natural transformation from f to g to a natural transformation from Coyoneda f to Coyoneda g .

as a Left Kan extension

coyonedaToLan :: Coyoneda f a -> Lan Identity f a Source #

Coyoneda f is the left Kan extension of f along the Identity functor.

Coyoneda f is always a functor, even if f is not. In this case, it is called the free functor over f . Note the following categorical fine print: If f is not a functor, Coyoneda f is actually not the left Kan extension of f along the Identity functor, but along the inclusion functor from the discrete subcategory of Hask which contains only identity functions as morphisms to the full category Hask . (This is because f , not being a proper functor, can only be interpreted as a categorical functor by restricting the source category to only contain identities.)

coyonedaToLan . lanToCoyonedaid
lanToCoyoneda . coyonedaToLanid