HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Moduleprofunctors-5.6.3Haskell2010

Data.Profunctor

For a good explanation of profunctors in Haskell see Dan Piponi's article:

http://blog.sigfpe.com/2011/07/profunctors-in-haskell.html

For more information on strength and costrength, see:

http://comonad.com/reader/2008/deriving-strength-from-laziness/

Contents
  1. Profunctors
  2. Profunctorial Strength
  3. Closed
  4. Profunctorial Costrength
  5. Common Profunctors
Synopsis
  • Packageprofunctors-5.6.3
  • Exports14
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceProfunctor.hs

Profunctors

classclass Profunctor (p :: Type -> Type -> Type) where

Formally, the class Profunctor represents a profunctor from Hask -> Hask.

Intuitively it is a bifunctor where the first argument is contravariant and the second argument is covariant.

You can define a Profunctor by either defining dimap or by defining both lmap and rmap.

If you supply dimap, you should ensure that:

dimap id id ≡ id

If you supply lmap and rmap, ensure:

lmap id ≡ id
rmap id ≡ id

If you supply both, you should also ensure:

dimap f g ≡ lmap f . rmap g

These ensure by parametricity:

dimap (f . g) (h . i) ≡ dimap g h . dimap f i
lmap (f . g) ≡ lmap g . lmap f
rmap (f . g) ≡ rmap f . rmap g

Methods

  • dimap :: (a -> b) -> (c -> d) -> p b c -> p a d

    Map over both arguments at the same time.

    dimap f g ≡ lmap f . rmap g
  • lmap :: (a -> b) -> p b c -> p a c

    Map the first argument contravariantly.

    lmap f ≡ dimap f id
  • rmap :: (b -> c) -> p a b -> p a c

    Map the second argument covariantly.

    rmap ≡ dimap id
Instances37Profunctor, …

Profunctorial Strength

classclass Profunctor p => Strong (p :: Type -> Type -> Type) where

Generalizing Star of a strong Functor

Note: Every Functor in Haskell is strong with respect to (,).

This describes profunctor strength with respect to the product structure of Hask.

http://www.riec.tohoku.ac.jp/~asada/papers/arrStrMnd.pdf

Methods

Instances20Strong, …
classclass Profunctor p => Choice (p :: Type -> Type -> Type) where

The generalization of Costar of Functor that is strong with respect to Either.

Note: This is also a notion of strength, except with regards to another monoidal structure that we can choose to equip Hask with: the cocartesian coproduct.

Methods

Instances22Choice, …

Closed

classclass Profunctor p => Closed (p :: Type -> Type -> Type) where

A strong profunctor allows the monoidal structure to pass through.

A closed profunctor allows the closed structure to pass through.

Methods

Instances17Closed, …
classclass (Traversing p, Closed p) => Mapping (p :: Type -> Type -> Type) where
#

Methods

Instances10Mapping, …

Profunctorial Costrength

classclass Profunctor p => Costrong (p :: Type -> Type -> Type) where

Analogous to ArrowLoop, loop = unfirst

Methods

Instances15Costrong, …
classclass Profunctor p => Cochoice (p :: Type -> Type -> Type) where
#

Methods

Instances12Cochoice, …

Common Profunctors

newtypenewtype Star (f :: k -> Type) d (c :: k)

Lift a Functor into a Profunctor (forwards).

Star has a polymorphic kind since 5.6.

Constructors

Instances18Category, Choice, Cochoice, Closed, Mapping, Strong, …
newtypenewtype Costar (f :: k -> Type) (d :: k) c

Lift a Functor into a Profunctor (backwards).

Costar has a polymorphic kind since 5.6.

Constructors

Instances11Cochoice, Closed, Costrong, Profunctor, Corepresentable, Cosieve, …
newtypenewtype WrappedArrow (p :: k -> k1 -> Type) (a :: k) (b :: k1)

Wrap an arrow for use as a Profunctor.

WrappedArrow has a polymorphic kind since 5.6.

Constructors

Instances10Category, Arrow, ArrowApply, ArrowChoice, ArrowZero, ArrowLoop, …
newtypenewtype Forget r a (b :: k)

Forget has a polymorphic kind since 5.6.

Constructors

Instances14Choice, Cochoice, Strong, Profunctor, Traversing, Representable, …
typetype (:->) (p :: k -> k1 -> Type) (q :: k -> k1 -> Type) = forall (a :: k) (b :: k1). p a b -> q a b

(:->) has a polymorphic kind since 5.6.