Copyright | (c) Edward Kmett 2011-2014 |
---|---|

License | BSD3 |

Maintainer | ekmett@gmail.com |

Stability | experimental |

Safe Haskell | None |

Language | Haskell98 |

Representable contravariant endofunctors over the category of Haskell
types are isomorphic to `(_ -> r)`

and resemble mappings to a
fixed range.

- class Contravariant f => Representable f where
- tabulated :: (Representable f, Representable g, Profunctor p, Functor h) => p (f a) (h (g b)) -> p (a -> Rep f) (h (b -> Rep g))
- contramapRep :: Representable f => (a -> b) -> f b -> f a

# Representable Contravariant Functors

class Contravariant f => Representable f where #

A `Contravariant`

functor `f`

is `Representable`

if `tabulate`

and `index`

witness an isomorphism to `(_ -> Rep f)`

.

`tabulate`

.`index`

≡ id`index`

.`tabulate`

≡ id

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

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

`contramapWithRep`

f p ≡`tabulate`

$`either`

(`index`

p)`id`

. f

Representable Predicate # | |

Representable (Proxy *) # | |

Representable (Op r) # | |

(Representable f, Representable g) => Representable (Product * f g) # | |

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

`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 a #