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

Copyright Copyright (C) 2015 Kyle Carter BSD3 Kyle Carter experimental RankNTypes None Haskell2010

Data.Type.Sum

Description

Sum is a type combinators for representing disjoint sums of indices (as :: [k]) of a single functor @(f :: k -> *). Contrast to the many-functors-one-index FSum

Synopsis

# Documentation

data Sum f :: [k] -> * where Source #

Constructors

 InL :: !(f a) -> Sum f (a :< as) InR :: !(Sum f as) -> Sum f (a :< as)

Instances

 (Witness p q (f a1), Witness p q (Sum a f ((:<) a b as))) => Witness p q (Sum a f ((:<) a a1 ((:<) a b as))) Source # Associated Typestype WitnessC (p :: Constraint) (q :: Constraint) (Sum a f ((:<) a a1 ((:<) a b as))) :: Constraint Source # Methods(\\) :: p => (q -> r) -> Sum a f ((a :< a1) ((a :< b) as)) -> r Source # Witness p q (f a) => Witness p q (Sum k f ((:) k a ([] k))) Source # Associated Typestype WitnessC (p :: Constraint) (q :: Constraint) (Sum k f ((:) k a ([] k))) :: Constraint Source # Methods(\\) :: p => (q -> r) -> Sum k f ((k ': a) [k]) -> r Source # IxTraversable1 k [k] (Index k) (Sum k) Source # Methodsitraverse1 :: Applicative h => (forall a. i b a -> f a -> h (g a)) -> t f b -> h (t g b) Source # IxFoldable1 k [k] (Index k) (Sum k) Source # MethodsifoldMap1 :: Monoid m => (forall a. i b a -> f a -> m) -> t f b -> m Source # IxFunctor1 k [k] (Index k) (Sum k) Source # Methodsimap1 :: (forall a. i b a -> f a -> g a) -> t f b -> t g b Source # Traversable1 [k] k (Sum k) Source # Methodstraverse1 :: Applicative h => (forall a. f a -> h (g a)) -> t f b -> h (t g b) Source # Foldable1 [k] k (Sum k) Source # MethodsfoldMap1 :: Monoid m => (forall a. f a -> m) -> t f b -> m Source # Functor1 [k] k (Sum k) Source # Methodsmap1 :: (forall a. f a -> g a) -> t f b -> t g b Source # Read1 k f => Read1 [k] (Sum k f) Source # MethodsreadsPrec1 :: Int -> ReadS (Some (Sum k f) f) Source # Show1 k f => Show1 [k] (Sum k f) Source # MethodsshowsPrec1 :: Int -> f a -> ShowS Source #show1 :: f a -> String Source # Ord1 k f => Ord1 [k] (Sum k f) Source # Methodscompare1 :: f a -> f a -> Ordering Source #(<#) :: f a -> f a -> Bool Source #(>#) :: f a -> f a -> Bool Source #(<=#) :: f a -> f a -> Bool Source #(>=#) :: f a -> f a -> Bool Source # Eq1 k f => Eq1 [k] (Sum k f) Source # Methodseq1 :: f a -> f a -> Bool Source #neq1 :: f a -> f a -> Bool Source # ListC ((<$>) Constraint * Eq ((<$>) * k f as)) => Eq (Sum k f as) Source # Methods(==) :: Sum k f as -> Sum k f as -> Bool #(/=) :: Sum k f as -> Sum k f as -> Bool # (ListC ((<$>) Constraint * Eq ((<$>) * k f as)), ListC ((<$>) Constraint * Ord ((<$>) * k f as))) => Ord (Sum k f as) Source # Methodscompare :: Sum k f as -> Sum k f as -> Ordering #(<) :: Sum k f as -> Sum k f as -> Bool #(<=) :: Sum k f as -> Sum k f as -> Bool #(>) :: Sum k f as -> Sum k f as -> Bool #(>=) :: Sum k f as -> Sum k f as -> Bool #max :: Sum k f as -> Sum k f as -> Sum k f as #min :: Sum k f as -> Sum k f as -> Sum k f as # ListC ((<$>) Constraint * Show ((<$>) * k f as)) => Show (Sum k f as) Source # MethodsshowsPrec :: Int -> Sum k f as -> ShowS #show :: Sum k f as -> String #showList :: [Sum k f as] -> ShowS # type WitnessC p q (Sum a f ((:<) a a1 ((:<) a b as))) Source # type WitnessC p q (Sum a f ((:<) a a1 ((:<) a b as))) = (Witness p q (f a1), Witness p q (Sum a f ((:<) a b as))) type WitnessC p q (Sum k f ((:) k a ([] k))) Source # type WitnessC p q (Sum k f ((:) k a ([] k))) = Witness p q (f a)

There are no possible values of the type Sum f Ø.

decomp :: Sum f (a :< as) -> Either (f a) (Sum f as) Source #

injectSum :: Index as a -> f a -> Sum f as Source #

inj :: a as => f a -> Sum f as Source #

prj :: a as => Sum f as -> Maybe (f a) Source #

index :: Index as a -> Sum f as -> Maybe (f a) Source #

elimSum :: (forall x xs. f x -> p (x :< xs)) -> (forall x xs. Index as x -> p xs -> p (x :< xs)) -> Sum f as -> p as Source #