kind-apply-0.3.2.0: Utilities to work with lists of types

Data.PolyKinded.Functor

Contents

Description

Poly-kinded Functor type class. KFunctor generalizes functors, bifunctors, profunctors, ... by declaring a list of Variances for a type constructor.

Synopsis

# Documentation

class KFunctor (f :: k) (v :: Variances) (as :: LoT k) (bs :: LoT k) | f -> v where Source #

Declares that the type constructor f is a generalized functor whose variances for each type argument are given by v.

Methods

kfmap :: Mappings v as bs -> (f :@@: as) -> f :@@: bs Source #

The generalized version of fmap, bimap, dimap, and so on.

kmapo :: forall f v as bs. KFunctor f v as bs => Mappings v as bs -> (f :@@: as) -> f :@@: bs Source #

The generalized version of fmap, bimap, dimap, and so on. This version uses Split to obtain better type inference.

## Mappings of different variance

data Variance Source #

Possible variances for each argument of a type constructor.

Constructors

 Co The functor is covariant in this position. Contra The functor is contravariant in this position. Phantom This position is not used in any constructor.

type family Mapping (v :: Variance) a b where ... Source #

If a KFunctor needs to map an f ... a ... to an f ... b ..., a Mapping v a b specifies which function needs to be provided for that position depending on its variance v.

Equations

 Mapping Co a b = a -> b Mapping Contra a b = b -> a Mapping Phantom a b = ()

data Mappings (v :: Variances) (x :: LoT k) (y :: LoT k) where Source #

List of mappings for the list of variances v.

Constructors

 M0 :: Mappings '[] LoT0 LoT0 (:^:) :: Mapping v a b -> Mappings vs as bs -> Mappings (v ': vs) (a :&&: as) (b :&&: bs) infixr 5