| Copyright | (C) 2011-2013 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 | Haskell98 |
Data.Functor.Coyoneda
Description
- data Coyoneda f a where
- liftCoyoneda :: f a -> Coyoneda f a
- lowerCoyoneda :: Functor f => Coyoneda f a -> f a
- lowerM :: Monad f => Coyoneda f a -> f a
- coyonedaToLan :: Coyoneda f a -> Lan Identity f a
- lanToCoyoneda :: Lan Identity f a -> Coyoneda f a
- coyonedaToLift :: Coyoneda f a -> Lift Identity f a
- liftToCoyoneda :: Functor f => Lift Identity f a -> Coyoneda f a
Documentation
data Coyoneda f a where Source
A covariant Functor suitable for Yoneda reduction
Instances
liftCoyoneda :: f a -> Coyoneda f a Source
Yoneda "expansion"
liftCoyoneda.lowerCoyoneda≡idlowerCoyoneda.liftCoyoneda≡id
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
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.
coyonedaToLan.lanToCoyoneda≡idlanToCoyoneda.coyonedaToLan≡id
lanToCoyoneda :: Lan Identity f a -> Coyoneda f a Source
as a Left Kan lift
coyonedaToLift :: Coyoneda f a -> Lift Identity f a Source
is the left Kan lift of Coyoneda ff along the Identity functor.
coyonedaToLift.liftToCoyoneda≡idliftToCoyoneda.coyonedaToLift≡id