adjunctions-4.4.3: Adjunctions and representable functors

Copyright | (C) 2011-2013 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | provisional
Portability | MPTCs
Safe Haskell | Trustworthy
Language | Haskell2010

Data.Functor.Contravariant.Adjunction

Description

Synopsis

- class (Contravariant f, Representable g) => Adjunction (f :: Type -> Type) (g :: Type -> Type) | f -> g, g -> f where
  - unit :: a -> g (f a)
  - counit :: a -> f (g a)
  - leftAdjunct :: (b -> f a) -> a -> g b
  - rightAdjunct :: (a -> g b) -> b -> f a
- adjuncted :: (Adjunction f g, Profunctor p, Functor h) => p (a -> g b) (h (c -> g d)) -> p (b -> f a) (h (d -> f c))
- contrarepAdjunction :: Adjunction f g => (a -> f ()) -> g a
- coindexAdjunction :: Adjunction f g => g a -> a -> f ()

# Documentation

class (Contravariant f, Representable g) => Adjunction (f :: Type -> Type) (g :: Type -> Type) | f -> g, g -> f where Source #

An adjunction from `Hask^op` to `Hask`

    Op (f a) b ~ Hask a (g b)

    rightAdjunct unit = id
    leftAdjunct counit = id

Any adjunction from `Hask` to `Hask^op` would indirectly permit `unsafePerformIO`, and therefore does not exist.

Minimal complete definition

unit, counit | leftAdjunct, rightAdjunct

Methods

unit :: a -> g (f a) Source #

counit :: a -> f (g a) Source #

leftAdjunct :: (b -> f a) -> a -> g b Source #

rightAdjunct :: (a -> g b) -> b -> f a Source #

#### Instances

Instances details

Adjunction Predicate Predicate Source # | This gives rise to the `Cont Bool` `Monad`
Instance details Defined in Data.Functor.Contravariant.Adjunction Methods unit :: a -> Predicate (Predicate a) Source # counit :: a -> Predicate (Predicate a) Source # leftAdjunct :: (b -> Predicate a) -> a -> Predicate b Source # rightAdjunct :: (a -> Predicate b) -> b -> Predicate a Source #
Adjunction (Op r) (Op r) Source # | This `Adjunction` gives rise to the `Cont` `Monad`
Instance details Defined in Data.Functor.Contravariant.Adjunction Methods unit :: a -> Op r (Op r a) Source # counit :: a -> Op r (Op r a) Source # leftAdjunct :: (b -> Op r a) -> a -> Op r b Source # rightAdjunct :: (a -> Op r b) -> b -> Op r a Source #

adjuncted :: (Adjunction f g, Profunctor p, Functor h) => p (a -> g b) (h (c -> g d)) -> p (b -> f a) (h (d -> f c)) Source #

`leftAdjunct` and `rightAdjunct` form two halves of an isomorphism.

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

    adjuncted :: Adjunction f g => Iso' (b -> f a) (a -> g b)

contrarepAdjunction :: Adjunction f g => (a -> f ()) -> g a Source #

Represent a `Contravariant` functor that has a left adjoint

coindexAdjunction :: Adjunction f g => g a -> a -> f () Source #