type-combinators-0.1.2.1: A collection of data types for type-level programming

CopyrightCopyright (C) 2015 Kyle Carter
LicenseBSD3
MaintainerKyle Carter <kylcarte@indiana.edu>
Stabilityexperimental
PortabilityRankNTypes
Safe HaskellNone
LanguageHaskell2010

Data.Type.Sum.Dual

Description

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.

Synopsis

Documentation

data FSum :: [k -> *] -> k -> * where Source

Constructors

FInL :: !(f a) -> FSum (f :< fs) a 
FInR :: !(FSum fs a) -> FSum (f :< fs) a 

Instances

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 

nilSumF :: FSum Ø a -> Void Source

There are no possible values of the type FSum Ø a.

decompF :: FSum (f :< fs) a -> Either (f a) (FSum fs a) Source

Decompose a non-empty FSum into either its head or its tail.

injF :: f fs => f a -> FSum fs a Source

Inject an element into an FSum.

prjF :: f fs => FSum fs a -> Maybe (f a) Source

Project an implicit index out of an FSum.

injectFSum :: Index fs f -> f a -> FSum fs a Source

Inject an element into an FSum with an explicitly specified Index.

indexF :: Index fs f -> FSum fs a -> Maybe (f a) Source

Project an explicit index out of an FSum.

imapF :: (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.

ifoldMapF :: (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!

itraverseF :: Functor g => (forall f. Index fs f -> f a -> g (f b)) -> FSum fs a -> g (FSum fs b) Source

Another fun fact: Since there is exactly one element in an FSum, we require only a Functor instance on g, rather than Applicative.