HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Modulekan-extensions-5.2.8Haskell2010

Data.Functor.Coyoneda

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.

Contents
  1. as a Left Kan extension
Synopsis
datadata Coyoneda (f :: Type -> Type) a where

A covariant Functor suitable for Yoneda reduction

Constructors

Instances30MonadTrans, ComonadTrans, Monad, Functor, MonadFix, Applicative, …
valuehoistCoyoneda :: (forall a. f a -> g a) -> Coyoneda f b -> Coyoneda g b

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

as a Left Kan extension

valuecoyonedaToLan :: Coyoneda f a -> Lan Identity f a

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 . lanToCoyoneda ≡ id
lanToCoyoneda . coyonedaToLan ≡ id