adjunctions-4.2: Adjunctions and representable functors

Stabilityexperimental
Maintainerekmett@gmail.com
Safe HaskellNone

Data.Functor.Contravariant.Rep

Contents

Description

Representable contravariant endofunctors over the category of Haskell types are isomorphic to (_ -> r) and resemble mappings to a fixed range.

Synopsis

Representable Contravariant Functors

class Contravariant f => Representable f whereSource

A Contravariant functor f is Representable if tabulate and index witness an isomorphism to (_ -> Rep f).

 tabulate . index ≡ id
 index . tabulate ≡ id

Associated Types

type Rep f :: *Source

Methods

tabulate :: (a -> Rep f) -> f aSource

 contramap f (tabulate g) = tabulate (g . f)

index :: f a -> a -> Rep fSource

contramapWithRep :: (b -> Either a (Rep f)) -> f a -> f bSource

tabulated :: (Representable f, Representable g, Profunctor p, Functor h) => p (f a) (h (g b)) -> p (a -> Rep f) (h (b -> Rep g))Source

tabulate and index form two halves of an isomorphism.

This can be used with the combinators from the lens package.

tabulated :: Representable f => Iso' (a -> Rep f) (f a)

Default definitions

contramapRep :: Representable f => (a -> b) -> f b -> f aSource