HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulekan-extensions-5.2.7Haskell2010

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.

  • 1 type
  • 6 values
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

2 declarations
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