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

Generics.MRSOP.Base.NS

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)

Instances

 ShowHO k phi => ShowHO [k] (NS k phi) Source # MethodsshowHO :: f k -> String Source # EqHO k phi => EqHO [k] (NS k phi) Source # MethodseqHO :: f k -> f k -> Bool Source # EqHO k phi => Eq (NS k phi xs) Source # Methods(==) :: NS k phi xs -> NS k phi xs -> Bool #(/=) :: NS k phi xs -> NS k phi xs -> Bool # ShowHO k phi => Show (NS k phi xs) Source # MethodsshowsPrec :: Int -> NS k phi xs -> ShowS #show :: NS k phi xs -> String #showList :: [NS k phi xs] -> ShowS #

# 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.