Copyright | Copyright (C) 2015 Kyle Carter |
---|---|
License | BSD3 |
Maintainer | Kyle Carter <kylcarte@indiana.edu> |
Stability | experimental |
Portability | RankNTypes |
Safe Haskell | None |
Language | Haskell2010 |
FSum
is a type combinators for representing disjoint sums of
many functors (fs :: [k -> *])
at a single index (a :: k)
.
As opposed to one-functor-many-indices Sum
.
- data FSum :: [k -> *] -> k -> * where
- nilFSum :: FSum Ø a -> Void
- fdecomp :: FSum (f :< fs) a -> Either (f a) (FSum fs a)
- finj :: f ∈ fs => f a -> FSum fs a
- fprj :: f ∈ fs => FSum fs a -> Maybe (f a)
- injectFSum :: Index fs f -> f a -> FSum fs a
- findex :: Index fs f -> FSum fs a -> Maybe (f a)
- imapFSum :: (forall f. Index fs f -> f a -> f b) -> FSum fs a -> FSum fs b
- ifoldMapFSum :: (forall f. Index fs f -> f a -> m) -> FSum fs a -> m
- itraverseFSum :: Functor g => (forall f. Index fs f -> f a -> g (f b)) -> FSum fs a -> g (FSum fs b)
Documentation
data FSum :: [k -> *] -> k -> * where Source #
ListC ((<$>) Constraint (* -> *) Functor fs) => Functor (FSum * fs) Source # | |
ListC ((<$>) Constraint (* -> *) Foldable fs) => Foldable (FSum * fs) Source # | |
(ListC ((<$>) Constraint (* -> *) Functor fs), ListC ((<$>) Constraint (* -> *) Foldable fs), ListC ((<$>) Constraint (* -> *) Traversable fs)) => Traversable (FSum * fs) Source # | |
fdecomp :: FSum (f :< fs) a -> Either (f a) (FSum fs a) Source #
Decompose a non-empty FSum into either its head or its tail.
injectFSum :: Index fs f -> f a -> FSum fs a Source #
Inject an element into an FSum with an explicitly specified Index.
imapFSum :: (forall f. Index fs f -> f a -> f b) -> FSum fs a -> FSum fs b Source #
Map over the single element in an FSum with a function that can handle any possible element, along with the element's index.
ifoldMapFSum :: (forall f. Index fs f -> f a -> m) -> FSum fs a -> m Source #
Fun fact: Since there is exactly one element in
an FSum, we don't need the Monoid
instance!