Generics.SOP.BasicFunctors

generics-sop-0.2.1.0: Generic Programming using True Sums of Products

Safe Haskell | Safe
Language | Haskell2010

Generics.SOP.BasicFunctors

Description

Basic functors.

Definitions of the type-level equivalents of `const`, `id`, and (`.`), and a definition of the lifted function space.

These datatypes are generally useful, but in this library, they're primarily used as parameters for the `NP`, `NS`, `POP`, and `SOP` types.

Synopsis

- newtype K a b = K a
- unK :: K a b -> a
- newtype I a = I a
- unI :: I a -> a
- newtype (f :.: g) p = Comp (f (g p))
- unComp :: (f :.: g) p -> f (g p)

# Documentation

newtype K a b

The constant type functor.

Like `Constant`, but kind-polymorphic in its second argument and with a shorter name.

Constructors

K a |

Instances

Functor (K * a) |
Monoid a => Applicative (K * a) |
Foldable (K * a) |
Traversable (K * a) |
Show a => Show (K k a b) |
Generic (K k a b) |
type Rep (K k a b) |
type Code (K * a0 b0) = (:) [*] ((:) * a0 ([] *)) ([] [*]) |

unK :: K a b -> a

Extract the contents of a `K` value.

newtype I a

The identity type functor.

Like `Identity`, but with a shorter name.

Constructors

I a |

Instances

Monad I |
Functor I |
Applicative I |
Foldable I |
Traversable I |
Show a => Show (I a) |
Generic (I a) |
type Rep (I a) |
type Code (I a0) = (:) [*] ((:) * a0 ([] *)) ([] [*]) |

unI :: I a -> a

Extract the contents of an `I` value.

newtype (f :.: g) p infixr 7

Composition of functors.

Like `Compose`, but kind-polymorphic and with a shorter name.

Constructors

Comp (f (g p)) |

Instances

(Functor f, Functor g) => Functor ((:.:) * * f g) |
Show (f (g p)) => Show ((:.:) l k f g p) |
Generic ((:.:) l k f g p) |
type Rep ((:.:) l k f g p) |
type Code ((:.:) * * f0 g0 p0) = (:) [*] ((:) * (f0 (g0 p0)) ([] *)) ([] [*]) |

unComp :: (f :.: g) p -> f (g p)

Extract the contents of a `Comp` value.