kan-extensions-5.2.5: Kan extensions, Kan lifts, the Yoneda lemma, and (co)density (co)monads
Copyright(C) 2011-2016 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityprovisional
PortabilityMPTCs, fundeps
Safe HaskellTrustworthy
LanguageHaskell2010

Data.Functor.Yoneda

Description

The covariant form of the Yoneda lemma states that f is naturally isomorphic to Yoneda f.

This is described in a rather intuitive fashion by Dan Piponi in

http://blog.sigfpe.com/2006/11/yoneda-lemma.html

Synopsis

Documentation

newtype Yoneda f a Source #

Yoneda f a can be viewed as the partial application of fmap to its second argument.

Constructors

Yoneda 

Fields

Instances

Instances details
ComonadTrans Yoneda Source # 
Instance details

Defined in Data.Functor.Yoneda

Methods

lower :: Comonad w => Yoneda w a -> w a Source #

MonadTrans Yoneda Source # 
Instance details

Defined in Data.Functor.Yoneda

Methods

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

(Functor f, MonadFree f m) => MonadFree f (Yoneda m) Source # 
Instance details

Defined in Data.Functor.Yoneda

Methods

wrap :: f (Yoneda m a) -> Yoneda m a Source #

Representable g => Representable (Yoneda g) Source # 
Instance details

Defined in Data.Functor.Yoneda

Associated Types

type Rep (Yoneda g) Source #

Methods

tabulate :: (Rep (Yoneda g) -> a) -> Yoneda g a Source #

index :: Yoneda g a -> Rep (Yoneda g) -> a Source #

MonadFix m => MonadFix (Yoneda m) Source # 
Instance details

Defined in Data.Functor.Yoneda

Methods

mfix :: (a -> Yoneda m a) -> Yoneda m a Source #

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

Defined in Data.Functor.Yoneda

Methods

fold :: Monoid m => Yoneda f m -> m Source #

foldMap :: Monoid m => (a -> m) -> Yoneda f a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Yoneda f a -> m Source #

foldr :: (a -> b -> b) -> b -> Yoneda f a -> b Source #

foldr' :: (a -> b -> b) -> b -> Yoneda f a -> b Source #

foldl :: (b -> a -> b) -> b -> Yoneda f a -> b Source #

foldl' :: (b -> a -> b) -> b -> Yoneda f a -> b Source #

foldr1 :: (a -> a -> a) -> Yoneda f a -> a Source #

foldl1 :: (a -> a -> a) -> Yoneda f a -> a Source #

toList :: Yoneda f a -> [a] Source #

null :: Yoneda f a -> Bool Source #

length :: Yoneda f a -> Int Source #

elem :: Eq a => a -> Yoneda f a -> Bool Source #

maximum :: Ord a => Yoneda f a -> a Source #

minimum :: Ord a => Yoneda f a -> a Source #

sum :: Num a => Yoneda f a -> a Source #

product :: Num a => Yoneda f a -> a Source #

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

Defined in Data.Functor.Yoneda

Methods

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

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

Defined in Data.Functor.Yoneda

Methods

liftCompare :: (a -> b -> Ordering) -> Yoneda f a -> Yoneda f b -> Ordering Source #

(Read1 f, Functor f) => Read1 (Yoneda f) Source # 
Instance details

Defined in Data.Functor.Yoneda

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Yoneda f a) Source #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Yoneda f a] Source #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Yoneda f a) Source #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Yoneda f a] Source #

Show1 f => Show1 (Yoneda f) Source # 
Instance details

Defined in Data.Functor.Yoneda

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Yoneda f a -> ShowS Source #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Yoneda f a] -> ShowS Source #

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

Defined in Data.Functor.Yoneda

Methods

traverse :: Applicative f0 => (a -> f0 b) -> Yoneda f a -> f0 (Yoneda f b) Source #

sequenceA :: Applicative f0 => Yoneda f (f0 a) -> f0 (Yoneda f a) Source #

mapM :: Monad m => (a -> m b) -> Yoneda f a -> m (Yoneda f b) Source #

sequence :: Monad m => Yoneda f (m a) -> m (Yoneda f a) Source #

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

Defined in Data.Functor.Yoneda

Methods

empty :: Yoneda f a Source #

(<|>) :: Yoneda f a -> Yoneda f a -> Yoneda f a Source #

some :: Yoneda f a -> Yoneda f [a] Source #

many :: Yoneda f a -> Yoneda f [a] Source #

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

Defined in Data.Functor.Yoneda

Methods

pure :: a -> Yoneda f a Source #

(<*>) :: Yoneda f (a -> b) -> Yoneda f a -> Yoneda f b Source #

liftA2 :: (a -> b -> c) -> Yoneda f a -> Yoneda f b -> Yoneda f c Source #

(*>) :: Yoneda f a -> Yoneda f b -> Yoneda f b Source #

(<*) :: Yoneda f a -> Yoneda f b -> Yoneda f a Source #

Functor (Yoneda f) Source # 
Instance details

Defined in Data.Functor.Yoneda

Methods

fmap :: (a -> b) -> Yoneda f a -> Yoneda f b Source #

(<$) :: a -> Yoneda f b -> Yoneda f a Source #

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

Defined in Data.Functor.Yoneda

Methods

(>>=) :: Yoneda m a -> (a -> Yoneda m b) -> Yoneda m b Source #

(>>) :: Yoneda m a -> Yoneda m b -> Yoneda m b Source #

return :: a -> Yoneda m a Source #

MonadPlus m => MonadPlus (Yoneda m) Source # 
Instance details

Defined in Data.Functor.Yoneda

Methods

mzero :: Yoneda m a Source #

mplus :: Yoneda m a -> Yoneda m a -> Yoneda m a Source #

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

Defined in Data.Functor.Yoneda

Methods

extract :: Yoneda w a -> a Source #

duplicate :: Yoneda w a -> Yoneda w (Yoneda w a) Source #

extend :: (Yoneda w a -> b) -> Yoneda w a -> Yoneda w b Source #

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

Defined in Data.Functor.Yoneda

Methods

distribute :: Functor f0 => f0 (Yoneda f a) -> Yoneda f (f0 a) Source #

collect :: Functor f0 => (a -> Yoneda f b) -> f0 a -> Yoneda f (f0 b) Source #

distributeM :: Monad m => m (Yoneda f a) -> Yoneda f (m a) Source #

collectM :: Monad m => (a -> Yoneda f b) -> m a -> Yoneda f (m b) Source #

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

Defined in Data.Functor.Yoneda

Methods

(<!>) :: Yoneda f a -> Yoneda f a -> Yoneda f a Source #

some :: Applicative (Yoneda f) => Yoneda f a -> Yoneda f [a] Source #

many :: Applicative (Yoneda f) => Yoneda f a -> Yoneda f [a] Source #

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

Defined in Data.Functor.Yoneda

Methods

(<.>) :: Yoneda f (a -> b) -> Yoneda f a -> Yoneda f b Source #

(.>) :: Yoneda f a -> Yoneda f b -> Yoneda f b Source #

(<.) :: Yoneda f a -> Yoneda f b -> Yoneda f a Source #

liftF2 :: (a -> b -> c) -> Yoneda f a -> Yoneda f b -> Yoneda f c Source #

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

Defined in Data.Functor.Yoneda

Methods

(>>-) :: Yoneda m a -> (a -> Yoneda m b) -> Yoneda m b Source #

join :: Yoneda m (Yoneda m a) -> Yoneda m a Source #

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

Defined in Data.Functor.Yoneda

Methods

duplicated :: Yoneda w a -> Yoneda w (Yoneda w a) Source #

extended :: (Yoneda w a -> b) -> Yoneda w a -> Yoneda w b Source #

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

Defined in Data.Functor.Yoneda

Methods

zero :: Yoneda f a Source #

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

Defined in Data.Functor.Yoneda

Methods

fold1 :: Semigroup m => Yoneda f m -> m Source #

foldMap1 :: Semigroup m => (a -> m) -> Yoneda f a -> m Source #

toNonEmpty :: Yoneda f a -> NonEmpty a Source #

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

Defined in Data.Functor.Yoneda

Methods

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

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

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

Defined in Data.Functor.Yoneda

Methods

unit :: a -> Yoneda g (Yoneda f a) Source #

counit :: Yoneda f (Yoneda g a) -> a Source #

leftAdjunct :: (Yoneda f a -> b) -> a -> Yoneda g b Source #

rightAdjunct :: (a -> Yoneda g b) -> Yoneda f a -> b Source #

(Functor f, Read (f a)) => Read (Yoneda f a) Source # 
Instance details

Defined in Data.Functor.Yoneda

Show (f a) => Show (Yoneda f a) Source # 
Instance details

Defined in Data.Functor.Yoneda

Methods

showsPrec :: Int -> Yoneda f a -> ShowS Source #

show :: Yoneda f a -> String Source #

showList :: [Yoneda f a] -> ShowS Source #

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

Defined in Data.Functor.Yoneda

Methods

(==) :: Yoneda f a -> Yoneda f a -> Bool Source #

(/=) :: Yoneda f a -> Yoneda f a -> Bool Source #

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

Defined in Data.Functor.Yoneda

Methods

compare :: Yoneda f a -> Yoneda f a -> Ordering Source #

(<) :: Yoneda f a -> Yoneda f a -> Bool Source #

(<=) :: Yoneda f a -> Yoneda f a -> Bool Source #

(>) :: Yoneda f a -> Yoneda f a -> Bool Source #

(>=) :: Yoneda f a -> Yoneda f a -> Bool Source #

max :: Yoneda f a -> Yoneda f a -> Yoneda f a Source #

min :: Yoneda f a -> Yoneda f a -> Yoneda f a Source #

type Rep (Yoneda g) Source # 
Instance details

Defined in Data.Functor.Yoneda

type Rep (Yoneda g) = Rep g

liftYoneda :: Functor f => f a -> Yoneda f a Source #

The natural isomorphism between f and Yoneda f given by the Yoneda lemma is witnessed by liftYoneda and lowerYoneda

liftYoneda . lowerYonedaid
lowerYoneda . liftYonedaid
lowerYoneda (liftYoneda fa) =         -- definition
lowerYoneda (Yoneda (f -> fmap f a)) -- definition
(f -> fmap f fa) id                  -- beta reduction
fmap id fa                            -- functor law
fa
lift = liftYoneda

lowerYoneda :: Yoneda f a -> f a Source #

maxF :: (Functor f, Ord (f a)) => Yoneda f a -> Yoneda f a -> Yoneda f a Source #

minF :: (Functor f, Ord (f a)) => Yoneda f a -> Yoneda f a -> Yoneda f a Source #

maxM :: (Monad m, Ord (m a)) => Yoneda m a -> Yoneda m a -> Yoneda m a Source #

minM :: (Monad m, Ord (m a)) => Yoneda m a -> Yoneda m a -> Yoneda m a Source #

as a right Kan extension

yonedaToRan :: Yoneda f a -> Ran Identity f a Source #

Yoneda f can be viewed as the right Kan extension of f along the Identity functor.

yonedaToRan . ranToYonedaid
ranToYoneda . yonedaToRanid