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

Safe HaskellSafe
LanguageHaskell2010

Generics.MRSOP.Base.NS

Contents

Description

Standard representation of n-ary sums.

Synopsis
  • data NS :: (k -> *) -> [k] -> * where
  • mapNS :: (f :-> g) -> NS f ks -> NS g ks
  • mapNSM :: Monad m => (forall x. f x -> m (g x)) -> NS f ks -> m (NS g ks)
  • elimNS :: (forall x. f x -> a) -> NS f ks -> a
  • zipNS :: MonadPlus m => NS ki xs -> NS kj xs -> m (NS (ki :*: kj) xs)
  • cataNS :: (forall x xs. f x -> r (x ': xs)) -> (forall x xs. r xs -> r (x ': xs)) -> NS f xs -> r xs
  • eqNS :: (forall x. p x -> p x -> Bool) -> NS p xs -> NS p xs -> Bool

Documentation

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

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
Eq1 ki => Eq1 (NS ki :: [k] -> Type) # 
Instance details

Defined in Generics.MRSOP.Base.NS

Methods

eq1 :: NS ki k0 -> NS ki k0 -> Bool #

Map, Zip and Elim

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

Maps over a sum

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

Maps a monadic function over a sum

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

Eliminates a sum

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

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 #

Consumes a value of type NS

Equality

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

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