generics-mrsop-1.0.0.1: Generic Programming with Mutually Recursive Sums of Products.

Safe HaskellSafe
LanguageHaskell2010

Generics.MRSOP.Base.NS

Contents

Description

Standard representation of n-ary sums.

Synopsis

Documentation

data NS :: (k -> *) -> [k] -> * where Source #

Indexed n-ary sums. This is analogous to the Any datatype in Agda. Combinations of Here and Theres are also called injections.

Constructors

There :: NS p xs -> NS p (x ': xs) 
Here :: p x -> NS p (x ': xs) 

Map, Zip and Elim

mapNS :: (f :-> g) -> NS f ks -> NS g ks Source #

Maps over a sum

mapNSM :: Monad m => (forall x. f x -> m (g x)) -> NS f ks -> m (NS g ks) Source #

Maps a monadic function over a sum

elimNS :: (forall x. f x -> a) -> NS f ks -> a Source #

Eliminates a sum

zipNS :: MonadPlus m => NS ki xs -> NS kj xs -> m (NS (ki :*: kj) xs) Source #

Combines two sums. Note that we have to fail if they are constructed from different injections.

Catamorphism

cataNS :: (forall x xs. f x -> r (x ': xs)) -> (forall x xs. r xs -> r (x ': xs)) -> NS f xs -> r xs Source #

Consumes a value of type NS

Equality

eqNS :: (forall x. p x -> p x -> Bool) -> NS p xs -> NS p xs -> Bool Source #

Compares two values of type NS using the provided function in case they are made of the same injection.