Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Standard representation of n-ary sums.
- 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
Map, Zip and Elim
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
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