Copyright | (c) 2010-2011 Patrick Bahr, Tom Hvitved |
---|---|
License | BSD3 |
Maintainer | Patrick Bahr <paba@diku.dk> |
Stability | experimental |
Portability | non-portable (GHC Extensions) |
Safe Haskell | Safe-Inferred |
Language | Haskell98 |
This module provides operators on functors.
- data (f :+: g) e
- fromInl :: (f :+: g) e -> Maybe (f e)
- fromInr :: (f :+: g) e -> Maybe (g e)
- caseF :: (f a -> b) -> (g a -> b) -> (f :+: g) a -> b
- data Pos
- data Emb
- type family GetEmb f g :: Emb
- type family Pick f g e1 r :: Emb
- type family Split f g :: Emb
- type family Pick2 e1 r :: Emb
- data EmbD e f g where
- class GetEmbD e f g where
- data SimpPos
- data Res
- type family DestrPos e :: Res
- type family ResLeft r :: Res
- type family ResRight r :: Res
- type family ResSum r e :: Res
- type family Or x y
- type family In p e :: Bool
- type family Duplicates' r :: Bool
- type family Duplicates e
- class NoDup b f g
- inj_ :: EmbD e f g -> f a -> g a
- type (:<:) f g = (GetEmbD (GetEmb f g) f g, NoDup (Duplicates (GetEmb f g)) f g)
- inj :: forall f g a. f :<: g => f a -> g a
- type (:=:) f g = (f :<: g, g :<: f)
- proj_ :: EmbD e f g -> g a -> Maybe (f a)
- proj :: forall f g a. f :<: g => g a -> Maybe (f a)
- spl :: f :<: (f1 :+: f2) => (f1 a -> b) -> (f2 a -> b) -> f a -> b
- data (f :*: g) a = (f a) :*: (g a)
- ffst :: (f :*: g) a -> f a
- fsnd :: (f :*: g) a -> g a
- data (f :&: a) e = (f e) :&: a
- class DistAnn s p s' | s' -> s, s' -> p where
- class RemA s s' | s -> s' where
- remA :: s a -> s' a
Documentation
data (f :+: g) e infixr 6 Source
Formal sum of signatures (functors).
GetEmbD (Found p) f g => GetEmbD (Found (GoRight p)) f ((:+:) g' g) | |
GetEmbD (Found p) f g => GetEmbD (Found (GoLeft p)) f ((:+:) g g') | |
(GetEmbD (Found p1) f1 g, GetEmbD (Found p2) f2 g) => GetEmbD (Found (Sum p1 p2)) ((:+:) f1 f2) g | |
(Functor f, Functor g) => Functor ((:+:) f g) | |
(Foldable f, Foldable g) => Foldable ((:+:) f g) | |
(Traversable f, Traversable g) => Traversable ((:+:) f g) | |
(ShowConstr f, ShowConstr g) => ShowConstr ((:+:) f g) | |
(ShowF f, ShowF g) => ShowF ((:+:) f g) | |
(ArbitraryF f, ArbitraryF g) => ArbitraryF ((:+:) f g) | Instances of |
(NFDataF f, NFDataF g) => NFDataF ((:+:) f g) | |
(EqF f, EqF g) => EqF ((:+:) f g) |
|
(OrdF f, OrdF g) => OrdF ((:+:) f g) |
|
(Render f, Render g) => Render ((:+:) f g) | |
(HasVars f v0, HasVars g v0) => HasVars ((:+:) f g) v | |
(Desugar f h, Desugar g h) => Desugar ((:+:) f g) h | |
DistAnn s p s' => DistAnn ((:+:) f s) p ((:+:) ((:&:) f p) s') | |
RemA s s' => RemA ((:+:) ((:&:) f p) s) ((:+:) f s') | |
(Eq (f a), Eq (g a)) => Eq ((:+:) f g a) | |
(Ord (f a), Ord (g a)) => Ord ((:+:) f g a) | |
(Show (f a), Show (g a)) => Show ((:+:) f g a) |
caseF :: (f a -> b) -> (g a -> b) -> (f :+: g) a -> b Source
Utility function to case on a functor sum, without exposing the internal representation of sums.
type family Duplicates' r :: Bool Source
Duplicates' (SingPos p) = False | |
Duplicates' (CompPos p e) = Or (In p e) (Duplicates' (DestrPos e)) |
type family Duplicates e Source
Duplicates (Found p) = Duplicates' (DestrPos p) |
type (:<:) f g = (GetEmbD (GetEmb f g) f g, NoDup (Duplicates (GetEmb f g)) f g) infixl 5 Source
The :<: constraint is a conjunction of two constraints. The first
one is used to construct the evidence that is used to implement the
injection and projection functions. The first constraint alone
would allow instances such as F :+: F :<: F
or F :+: (F :+: G)
:<: F :+: G
which have multiple occurrences of the same
sub-signature on the left-hand side. Such instances are usually
unintended and yield injection functions that are not
injective. The second constraint excludes such instances.
data (f :&: a) e infixr 7 Source
This data type adds a constant product (annotation) to a signature.
(f e) :&: a infixr 7 |
DistAnn f p ((:&:) f p) | |
Functor f => Functor ((:&:) f a) | |
Foldable f => Foldable ((:&:) f a) | |
Traversable f => Traversable ((:&:) f a) | |
(ShowConstr f, Show p) => ShowConstr ((:&:) f p) | |
(ShowF f, Show p) => ShowF ((:&:) f p) | |
(ArbitraryF f, Arbitrary p) => ArbitraryF ((:&:) f p) | |
(NFDataF f, NFData a) => NFDataF ((:&:) f a) | |
RemA ((:&:) f p) f | |
DistAnn s p s' => DistAnn ((:+:) f s) p ((:+:) ((:&:) f p) s') | |
RemA s s' => RemA ((:+:) ((:&:) f p) s) ((:+:) f s') |