natural-transformation-0.4.1: A natural transformation package.

Copyright | (C) 2015 The University of Kansas
License | BSD-style (see the file LICENSE)
Maintainer | Andy Gill
Stability | Experimental
Safe Haskell | Safe
Language | Haskell2010

Control.Natural

Contents

- Newtype for a Natural Transformation
- Type Synonym for a Natural Transformation
- Conversion functions between the newtype and the synonym
- Class for Natural Transformations

Description

A data type and class for natural transformations.

Synopsis

- newtype (f :: k -> Type) :~> (g :: k -> Type) = NT {
  - ($$) :: f ~> g
  }
- type (~>) (f :: k -> Type) (g :: k -> Type) = forall (x :: k). f x -> g x
- wrapNT :: (forall (a :: k). f a -> g a) -> f :~> g
- unwrapNT :: Transformation f g t => t -> forall (a :: k). f a -> g a
- class Transformation (f :: k -> Type) (g :: k -> Type) t | t -> f g where
  - (#) :: t -> forall (a :: k). f a -> g a

# Newtype for a Natural Transformation

newtype (f :: k -> Type) :~> (g :: k -> Type) infixr 0 Source #

A natural transformation suitable for storing in a container.

Constructors

NT |

Fields

- ($$) :: f ~> g

#### Instances

Instances details

Transformation (f :: k -> Type) (g :: k -> Type) (f :~> g) Source # |
Instance details Defined in Control.Natural Methods (#) :: (f :~> g) -> forall (a :: k). f a -> g a Source #
Category ((:~>) :: (k -> Type) -> (k -> Type) -> Type) Source # |
Instance details Defined in Control.Natural Methods id :: forall (a :: k -> Type). a :~> a Source # (.) :: forall (b :: k -> Type) (c :: k -> Type) (a :: k -> Type). (b :~> c) -> (a :~> b) -> a :~> c Source #
f ~ g => Monoid (f :~> g) Source # |
Instance details Defined in Control.Natural Methods mempty :: f :~> g Source # mappend :: (f :~> g) -> (f :~> g) -> f :~> g Source # mconcat :: [f :~> g] -> f :~> g Source #
f ~ g => Semigroup (f :~> g) Source # |
Instance details Defined in Control.Natural Methods (<>) :: (f :~> g) -> (f :~> g) -> f :~> g Source # sconcat :: NonEmpty (f :~> g) -> f :~> g Source # stimes :: Integral b => b -> (f :~> g) -> f :~> g Source #

# Type Synonym for a Natural Transformation

type (~>) (f :: k -> Type) (g :: k -> Type) = forall (x :: k). f x -> g x infixr 0 Source #

A natural transformation from `f` to `g`.

# Conversion functions between the newtype and the synonym

wrapNT :: (forall (a :: k). f a -> g a) -> f :~> g Source #

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

An alias to `NT` provided for symmetry with `unwrapNT`.

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

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

# Class for Natural Transformations

class Transformation (f :: k -> Type) (g :: k -> Type) t | t -> f g where Source #

A (natural) transformation is inside `t`, and contains `f` and `g` (typically `Functor`s).

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 a infix 0 Source #

The invocation method for a natural transformation.

#### Instances

Instances details

Transformation (f :: Type -> Type) IO (Object f) Source # |
Instance details Defined in Control.Object Methods (#) :: Object f -> forall a. f a -> IO a Source #
Transformation (f :: k -> Type) (g :: k -> Type) (f :~> g) Source # |
Instance details Defined in Control.Natural Methods (#) :: (f :~> g) -> forall (a :: k). f a -> g a Source #