compdata-0.8.1.3: Compositional Data Types

Copyright(c) 2010-2011 Patrick Bahr, Tom Hvitved
LicenseBSD3
MaintainerPatrick Bahr <paba@diku.dk>
Stabilityexperimental
Portabilitynon-portable (GHC Extensions)
Safe HaskellSafe-Inferred
LanguageHaskell98

Data.Comp.Ops

Description

This module provides operators on functors.

Synopsis

Documentation

data (f :+: g) e infixr 6 Source

Formal sum of signatures (functors).

Constructors

Inl (f e) 
Inr (g e) 

Instances

DistAnn k s p s' => DistAnn k ((:+:) k f s) p ((:+:) k ((:&:) k f p) s') 
RemA k s s' => RemA k ((:+:) k ((:&:) k f p) s) ((:+:) k f s') 
(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 ArbitraryF are closed under forming sums.

(NFDataF f, NFDataF g) => NFDataF ((:+:) * f g) 
(EqF f, EqF g) => EqF ((:+:) * f g)

EqF is propagated through sums.

(OrdF f, OrdF g) => OrdF ((:+:) * f g)

OrdF is propagated through sums.

(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 
(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) 

fromInl :: (f :+: g) e -> Maybe (f e) Source

fromInr :: (f :+: g) e -> Maybe (g e) Source

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 Elem f g :: Emb Source

Equations

Elem f f = Found Here 
Elem (f1 :+: f2) g = Sum' (Elem f1 g) (Elem f2 g) 
Elem f (g1 :+: g2) = Choose (Elem f g1) (Elem f g2) 
Elem f g = NotFound 

type family Choose e1 r :: Emb Source

Equations

Choose (Found x) (Found y) = Ambiguous 
Choose Ambiguous y = Ambiguous 
Choose x Ambiguous = Ambiguous 
Choose (Found x) y = Found (Le x) 
Choose x (Found y) = Found (Ri y) 
Choose x y = NotFound 

type family Sum' e1 r :: Emb Source

Equations

Sum' (Found x) (Found y) = Found (Sum x y) 
Sum' Ambiguous y = Ambiguous 
Sum' x Ambiguous = Ambiguous 
Sum' NotFound y = NotFound 
Sum' x NotFound = NotFound 

data Proxy a Source

Constructors

P 

class Subsume e f g where Source

Methods

inj' :: Proxy e -> f a -> g a Source

prj' :: Proxy e -> g a -> Maybe (f a) Source

type (:<:) f g = Subsume (ComprEmb (Elem f g)) f g infixl 5 Source

A constraint f :<: g expresses that the signature f is subsumed by g, i.e. f can be used to construct elements in g.

inj :: forall f g a. f :<: g => f a -> g a Source

proj :: forall f g a. f :<: g => g a -> Maybe (f a) Source

type (:=:) f g = (f :<: g, g :<: f) infixl 5 Source

spl :: f :=: (f1 :+: f2) => (f1 a -> b) -> (f2 a -> b) -> f a -> b Source

data (f :*: g) a infixr 8 Source

Formal product of signatures (functors).

Constructors

(f a) :*: (g a) infixr 8 

ffst :: (f :*: g) a -> f a Source

fsnd :: (f :*: g) a -> g a Source

data (f :&: a) e infixr 7 Source

This data type adds a constant product (annotation) to a signature.

Constructors

(f e) :&: a infixr 7 

Instances

DistAnn k f p ((:&:) k f p) 
RemA k ((:&:) k f p) f 
DistAnn k s p s' => DistAnn k ((:+:) k f s) p ((:+:) k ((:&:) k f p) s') 
RemA k s s' => RemA k ((:+:) k ((:&:) k f p) s) ((:+:) k f s') 
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) 

class DistAnn s p s' | s' -> s, s' -> p where Source

This class defines how to distribute an annotation over a sum of signatures.

Methods

injectA :: p -> s a -> s' a Source

Inject an annotation over a signature.

projectA :: s' a -> (s a, p) Source

Project an annotation from a signature.

Instances

DistAnn k f p ((:&:) k f p) 
DistAnn k s p s' => DistAnn k ((:+:) k f s) p ((:+:) k ((:&:) k f p) s') 

class RemA s s' | s -> s' where Source

Methods

remA :: s a -> s' a Source

Remove annotations from a signature.

Instances

RemA k ((:&:) k f p) f 
RemA k s s' => RemA k ((:+:) k ((:&:) k f p) s) ((:+:) k f s')