representable-functors-0.3.0.3: Representable functors

Stabilityexperimental
Maintainerekmett@gmail.com

Data.Functor.Corepresentable

Contents

Description

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

Synopsis

Values

type family Value f Source

Contravariant Keyed

class Contravariant f => Valued f whereSource

Dual to Keyed.

Methods

contramapWithValue :: (b -> Either a (Value f)) -> f a -> f bSource

Instances

Contravariant Indexed

class Coindexed f whereSource

Dual to Indexed.

Methods

coindex :: f a -> a -> Value fSource

Representable Contravariant Functors

class (Coindexed f, Valued f) => Corepresentable f whereSource

A Functor f is Corepresentable if corep and coindex witness an isomorphism to (_ -> Value f).

 tabulate . index = id
 index . tabulate = id
 tabulate . return f = return f

Methods

corep :: (a -> Value f) -> f aSource

 contramap f (corep g) = corep (g . f)

Default definitions

contramapDefault :: Corepresentable f => (a -> b) -> f b -> f aSource

contramapWithValueDefault :: Corepresentable f => (b -> Either a (Value f)) -> f a -> f bSource