HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleprofunctors-5.6.3Haskell2010

Data.Profunctor.Types

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/

  • 5 types
  • 1 class
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, …
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, ArrowLoop, ArrowZero, …
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.