HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulenatural-transformation-0.4Haskell2010

Control.Natural

A data type and class for natural transformations.

  • 2 types
  • 1 class
  • 2 values

Newtype for a Natural Transformation

1 declaration
newtypenewtype (:~>) (f :: k -> Type) (g :: k -> Type)
#

A natural transformation suitable for storing in a container.

Constructors

Instances4Transformation, Category, Semigroup, Monoid
  • Transformation f g (f :~> g)Defined in natural-transformation-0.4 · Control.Natural
  • Category (:~>)Defined in natural-transformation-0.4 · Control.Natural
  • f ~ g => Semigroup (f :~> g)Defined in natural-transformation-0.4 · Control.Natural
  • f ~ g => Monoid (f :~> g)Defined in natural-transformation-0.4 · Control.Natural

Type Synonym for a Natural Transformation

1 declaration
typetype (~>) (f :: k -> Type) (g :: k -> Type) = forall (x :: k). f x -> g x
#

A natural transformation from f to g.

Conversion functions between the newtype and the synonym

2 declarations
valuewrapNT :: (forall (a :: k). f a -> g a) -> f :~> g
#

wrapNT builds our natural transformation abstraction out of a natural transformation function.

An alias to NT provided for symmetry with unwrapNT.

valueunwrapNT :: Transformation f g t => t -> forall (a :: k). f a -> g a
#

unwrapNT is the nonfix version of #. It is used to break natural transformation wrappers, including :~>.

Class for Natural Transformations

1 declaration
classclass Transformation (f :: k -> Type) (g :: k -> Type) t | t -> f g where
#

A (natural) transformation is inside t, and contains f and g (typically Functors).

The order of arguments allows the use of GeneralizedNewtypeDeriving to wrap a :~>, but maintain the Transformation constraint. Thus, # can be used on abstract data types.

Methods

  • (#) :: t -> forall (a :: k). f a -> g ainfix 0

    The invocation method for a natural transformation.

Instances2Transformation