kind-apply- Utilities to work with lists of types

Safe HaskellSafe




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



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.


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

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

kmapo :: forall t f v as bs. (Split t f as, KFunctor f v as bs) => Mappings v as bs -> t -> 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.



The functor is covariant in this position.


The functor is contravariant in this position.


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.


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.


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