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

Modulenatural-transformation-0.4.1Haskell2010

Control.Natural

A data type and class for natural transformations.

Contents
  1. Newtype for a Natural Transformation
  2. Type Synonym for a Natural Transformation
  3. Conversion functions between the newtype and the synonym
  4. Class for Natural Transformations
Synopsis

Newtype for a Natural Transformation

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.1 · Control.Natural
  • Category (:~>)Defined in natural-transformation-0.4.1 · Control.Natural
  • f ~ g => Semigroup (f :~> g)Defined in natural-transformation-0.4.1 · Control.Natural
  • f ~ g => Monoid (f :~> g)Defined in natural-transformation-0.4.1 · Control.Natural

Type Synonym for a Natural Transformation

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

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.

Class for Natural Transformations

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