profunctors-5.6.2: Profunctors

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

Data.Profunctor.Rep

Contents

- Representable Profunctors
- Corepresentable Profunctors
- Prep -| Star
- Coprep -| Costar

Description

Synopsis

- class (Sieve p (Rep p), Strong p) => Representable (p :: Type -> Type -> Type) where
  - type Rep (p :: Type -> Type -> Type) :: Type -> Type
  - tabulate :: (d -> Rep p c) -> p d c
- tabulated :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) d c d' c'. (Representable p, Representable q) => Iso (d -> Rep p c) (d' -> Rep q c') (p d c) (q d' c')
- firstRep :: Representable p => p a b -> p (a, c) (b, c)
- secondRep :: Representable p => p a b -> p (c, a) (c, b)
- class (Cosieve p (Corep p), Costrong p) => Corepresentable (p :: Type -> Type -> Type) where
  - type Corep (p :: Type -> Type -> Type) :: Type -> Type
  - cotabulate :: (Corep p d -> c) -> p d c
- cotabulated :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) d c d' c'. (Corepresentable p, Corepresentable q) => Iso (Corep p d -> c) (Corep q d' -> c') (p d c) (q d' c')
- unfirstCorep :: Corepresentable p => p (a, d) (b, d) -> p a b
- unsecondCorep :: Corepresentable p => p (d, a) (d, b) -> p a b
- closedCorep :: Corepresentable p => p a b -> p (x -> a) (x -> b)
- data Prep (p :: Type -> k -> Type) (a :: k) where
  - Prep :: forall {k} x (p :: Type -> k -> Type) (a :: k). x -> p x a -> Prep p a
- prepAdj :: forall {k1} (p :: Type -> k1 -> Type) g. (forall (a :: k1). Prep p a -> g a) -> p :-> Star g
- unprepAdj :: forall {k} (p :: Type -> k -> Type) g (a :: k). (p :-> Star g) -> Prep p a -> g a
- prepUnit :: forall {k} p a (b :: k). p a b -> Star (Prep p) a b
- prepCounit :: forall {k} f (a :: k). Prep (Star f) a -> f a
- newtype Coprep (p :: k -> Type -> Type) (a :: k) = Coprep {
  - runCoprep :: forall r. p a r -> r
  }
- coprepAdj :: forall {k} f (p :: k -> Type -> Type). (forall (a :: k). f a -> Coprep p a) -> p :-> Costar f
- uncoprepAdj :: forall {k} (p :: k -> Type -> Type) f (a :: k). (p :-> Costar f) -> f a -> Coprep p a
- coprepUnit :: forall {k} p (a :: k) b. p a b -> Costar (Coprep p) a b
- coprepCounit :: forall {k} f (a :: k). f a -> Coprep (Costar f) a

# Representable Profunctors

class (Sieve p (Rep p), Strong p) => Representable (p :: Type -> Type -> Type) where #

A `Profunctor` `p` is `Representable` if there exists a `Functor` `f` such that `p d c` is isomorphic to `d -> f c`.

Associated Types

type Rep (p :: Type -> Type -> Type) :: Type -> Type #

Methods

tabulate :: (d -> Rep p c) -> p d c #

Laws:

    tabulate . sieve ≡ id
    sieve . tabulate ≡ id

#### Instances

Instances details

(Monad m, Functor m) => Representable (Kleisli m) # |

Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Rep (Kleisli m) |
Instance details Defined in Data.Profunctor.Rep type Rep (Kleisli m) = m

Methods

tabulate :: (d -> Rep (Kleisli m) c) -> Kleisli m d c #

Representable (Forget r :: Type -> Type -> Type) # |

Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Rep (Forget r :: Type -> Type -> Type) |
Instance details Defined in Data.Profunctor.Rep type Rep (Forget r :: Type -> Type -> Type) = Const r :: Type -> Type

Methods

tabulate :: (d -> Rep (Forget r :: Type -> Type -> Type) c) -> Forget r d c #

Functor f => Representable (Star f) # |

Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Rep (Star f) |
Instance details Defined in Data.Profunctor.Rep type Rep (Star f) = f

Methods

tabulate :: (d -> Rep (Star f) c) -> Star f d c #

Representable (->) # |

Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Rep (->) |
Instance details Defined in Data.Profunctor.Rep type Rep (->) = Identity

Methods

tabulate :: (d -> Rep (->) c) -> d -> c #

(Representable p, Representable q) => Representable (Procompose p q) # | The composition of two `Representable` `Profunctor`s is `Representable` by the composition of their representations.

Instance details

Defined in Data.Profunctor.Composition

Associated Types

type Rep (Procompose p q) |
Instance details Defined in Data.Profunctor.Composition type Rep (Procompose p q) = Compose (Rep q) (Rep p)

Methods

tabulate :: (d -> Rep (Procompose p q) c) -> Procompose p q d c #

tabulated :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) d c d' c'. (Representable p, Representable q) => Iso (d -> Rep p c) (d' -> Rep q c') (p d c) (q d' c') #

`tabulate` and `sieve` form two halves of an isomorphism.

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

    tabulated :: Representable p => Iso' (d -> Rep p c) (p d c)

firstRep :: Representable p => p a b -> p (a, c) (b, c) #

Default definition for `first'` given that p is `Representable`.

secondRep :: Representable p => p a b -> p (c, a) (c, b) #

Default definition for `second'` given that p is `Representable`.

# Corepresentable Profunctors

class (Cosieve p (Corep p), Costrong p) => Corepresentable (p :: Type -> Type -> Type) where #

A `Profunctor` `p` is `Corepresentable` if there exists a `Functor` `f` such that `p d c` is isomorphic to `f d -> c`.

Associated Types

type Corep (p :: Type -> Type -> Type) :: Type -> Type #

Methods

cotabulate :: (Corep p d -> c) -> p d c #

Laws:

    cotabulate . cosieve ≡ id
    cosieve . cotabulate ≡ id

#### Instances

Instances details

Corepresentable (Tagged :: Type -> Type -> Type) # |

Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Corep (Tagged :: Type -> Type -> Type) |
Instance details Defined in Data.Profunctor.Rep type Corep (Tagged :: Type -> Type -> Type) = Proxy :: Type -> Type

Methods

cotabulate :: (Corep (Tagged :: Type -> Type -> Type) d -> c) -> Tagged d c #

Functor w => Corepresentable (Cokleisli w) # |

Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Corep (Cokleisli w) |
Instance details Defined in Data.Profunctor.Rep type Corep (Cokleisli w) = w

Methods

cotabulate :: (Corep (Cokleisli w) d -> c) -> Cokleisli w d c #

Functor f => Corepresentable (Costar f) # |

Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Corep (Costar f) |
Instance details Defined in Data.Profunctor.Rep type Corep (Costar f) = f

Methods

cotabulate :: (Corep (Costar f) d -> c) -> Costar f d c #

Corepresentable (->) # |

Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Corep (->) |
Instance details Defined in Data.Profunctor.Rep type Corep (->) = Identity

Methods

cotabulate :: (Corep (->) d -> c) -> d -> c #

(Corepresentable p, Corepresentable q) => Corepresentable (Procompose p q) # |

Instance details

Defined in Data.Profunctor.Composition

Associated Types

type Corep (Procompose p q) |
Instance details Defined in Data.Profunctor.Composition type Corep (Procompose p q) = Compose (Corep p) (Corep q)

Methods

cotabulate :: (Corep (Procompose p q) d -> c) -> Procompose p q d c #

cotabulated :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) d c d' c'. (Corepresentable p, Corepresentable q) => Iso (Corep p d -> c) (Corep q d' -> c') (p d c) (q d' c') #

`cotabulate` and `cosieve` form two halves of an isomorphism.

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

    cotabulated :: Corep f p => Iso' (f d -> c) (p d c)

unfirstCorep :: Corepresentable p => p (a, d) (b, d) -> p a b #

Default definition for `unfirst` given that `p` is `Corepresentable`.

unsecondCorep :: Corepresentable p => p (d, a) (d, b) -> p a b #

Default definition for `unsecond` given that `p` is `Corepresentable`.

closedCorep :: Corepresentable p => p a b -> p (x -> a) (x -> b) #

Default definition for `closed` given that `p` is `Corepresentable`

# Prep -| Star

data Prep (p :: Type -> k -> Type) (a :: k) where #

    Prep -| Star :: [Hask, Hask] -> Prof

This gives rise to a monad in `Prof`, `(`Star`.`Prep`)`, and a comonad in `[Hask,Hask]` `(`Prep`.`Star`)`

`Prep` has a polymorphic kind since `5.6`.

Constructors

Prep :: forall {k} x (p :: Type -> k -> Type) (a :: k). x -> p x a -> Prep p a |

#### Instances

Instances details

(Applicative (Rep p), Representable p) => Applicative (Prep p) # |
Instance details Defined in Data.Profunctor.Rep Methods pure :: a -> Prep p a # (<*>) :: Prep p (a -> b) -> Prep p a -> Prep p b # liftA2 :: (a -> b -> c) -> Prep p a -> Prep p b -> Prep p c # (*>) :: Prep p a -> Prep p b -> Prep p b # (<*) :: Prep p a -> Prep p b -> Prep p a #
Profunctor p => Functor (Prep p) # |
Instance details Defined in Data.Profunctor.Rep Methods fmap :: (a -> b) -> Prep p a -> Prep p b # (<$) :: a -> Prep p b -> Prep p a #
(Monad (Rep p), Representable p) => Monad (Prep p) # |
Instance details Defined in Data.Profunctor.Rep Methods (>>=) :: Prep p a -> (a -> Prep p b) -> Prep p b # (>>) :: Prep p a -> Prep p b -> Prep p b # return :: a -> Prep p a #

prepAdj :: forall {k1} (p :: Type -> k1 -> Type) g. (forall (a :: k1). Prep p a -> g a) -> p :-> Star g #

unprepAdj :: forall {k} (p :: Type -> k -> Type) g (a :: k). (p :-> Star g) -> Prep p a -> g a #

prepUnit :: forall {k} p a (b :: k). p a b -> Star (Prep p) a b #

prepCounit :: forall {k} f (a :: k). Prep (Star f) a -> f a #

# Coprep -| Costar

newtype Coprep (p :: k -> Type -> Type) (a :: k) #

`Prep` has a polymorphic kind since `5.6`.

Constructors

Coprep |

Fields

- runCoprep :: forall r. p a r -> r

#### Instances

Instances details

Profunctor p => Functor (Coprep p) # |
Instance details Defined in Data.Profunctor.Rep Methods fmap :: (a -> b) -> Coprep p a -> Coprep p b # (<$) :: a -> Coprep p b -> Coprep p a #

coprepAdj :: forall {k} f (p :: k -> Type -> Type). (forall (a :: k). f a -> Coprep p a) -> p :-> Costar f #

    Coprep -| Costar :: [Hask, Hask]^op -> Prof

Like all adjunctions this gives rise to a monad and a comonad.

This gives rise to a monad on Prof `(`Costar`.`Coprep`)` and a comonad on `[Hask, Hask]^op` given by `(`Coprep`.`Costar`)` which is a monad in `[Hask,Hask]`

uncoprepAdj :: forall {k} (p :: k -> Type -> Type) f (a :: k). (p :-> Costar f) -> f a -> Coprep p a #

coprepUnit :: forall {k} p (a :: k) b. p a b -> Costar (Coprep p) a b #

coprepCounit :: forall {k} f (a :: k). f a -> Coprep (Costar f) a #