compdata-0.12: Compositional Data Types

Copyright(c) 2011 Patrick Bahr
LicenseBSD3
MaintainerPatrick Bahr <paba@diku.dk>
Stabilityexperimental
Portabilitynon-portable (GHC Extensions)
Safe HaskellNone
LanguageHaskell98

Data.Comp.Multi.Sum

Contents

Description

This module defines sums on signatures. All definitions are generalised versions of those in Data.Comp.Sum.

Synopsis

Documentation

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.

data (f :+: g) (h :: * -> *) e infixr 6 Source #

Data type defining coproducts.

Instances
(HFunctor f, HFunctor g) => HFunctor (f :+: g) Source # 
Instance details

Defined in Data.Comp.Multi.Ops

Methods

hfmap :: (f0 :-> g0) -> (f :+: g) f0 :-> (f :+: g) g0 Source #

(HFoldable f, HFoldable g) => HFoldable (f :+: g) Source # 
Instance details

Defined in Data.Comp.Multi.Ops

Methods

hfold :: Monoid m => (f :+: g) (K m) :=> m Source #

hfoldMap :: Monoid m => (a :=> m) -> (f :+: g) a :=> m Source #

hfoldr :: (a :=> (b -> b)) -> b -> (f :+: g) a :=> b Source #

hfoldl :: (b -> a :=> b) -> b -> (f :+: g) a :=> b Source #

hfoldr1 :: (a -> a -> a) -> (f :+: g) (K a) :=> a Source #

hfoldl1 :: (a -> a -> a) -> (f :+: g) (K a) :=> a Source #

(HTraversable f, HTraversable g) => HTraversable (f :+: g) Source # 
Instance details

Defined in Data.Comp.Multi.Ops

Methods

hmapM :: Monad m => NatM m a b -> NatM m ((f :+: g) a) ((f :+: g) b) Source #

htraverse :: Applicative f0 => NatM f0 a b -> NatM f0 ((f :+: g) a) ((f :+: g) b) Source #

(ShowHF f, ShowHF g) => ShowHF (f :+: g) Source # 
Instance details

Defined in Data.Comp.Multi.Show

Methods

showHF :: Alg (f :+: g) (K String) Source #

showHF' :: (f :+: g) (K String) :=> String Source #

(EqHF f, EqHF g) => EqHF (f :+: g) Source #

EqF is propagated through sums.

Instance details

Defined in Data.Comp.Multi.Equality

Methods

eqHF :: KEq g0 => (f :+: g) g0 i -> (f :+: g) g0 j -> Bool Source #

(OrdHF f, OrdHF g) => OrdHF (f :+: g) Source #

OrdHF is propagated through sums.

Instance details

Defined in Data.Comp.Multi.Ordering

Methods

compareHF :: KOrd a => (f :+: g) a i -> (f :+: g) a j -> Ordering Source #

(HasVars f v, HasVars g v) => HasVars (f :+: g) v Source # 
Instance details

Defined in Data.Comp.Multi.Variables

Methods

isVar :: (f :+: g) a i -> Maybe v Source #

bindsVars :: Mapping m a => (f :+: g) a :=> m (Set v) Source #

(Desugar f h, Desugar g h) => Desugar (f :+: g) h Source # 
Instance details

Defined in Data.Comp.Multi.Desugar

Methods

desugHom :: Hom (f :+: g) h Source #

desugHom' :: (f :+: g) (Context h a) i -> Context h a i Source #

DistAnn s p s' => DistAnn (f :+: s) p ((f :&: p) :+: s') Source # 
Instance details

Defined in Data.Comp.Multi.Ops

Methods

injectA :: p -> (f :+: s) a :-> ((f :&: p) :+: s') a Source #

projectA :: ((f :&: p) :+: s') a i -> ((f :+: s) a :&: p) i Source #

RemA s s' => RemA ((f :&: p) :+: s) (f :+: s') Source # 
Instance details

Defined in Data.Comp.Multi.Ops

Methods

remA :: ((f :&: p) :+: s) a i -> (f :+: s') a i Source #

caseH :: (f a b -> c) -> (g a b -> c) -> (f :+: g) a b -> c Source #

Utility function to case on a higher-order functor sum, without exposing the internal representation of sums.

Projections for Signatures and Terms

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

project :: g :<: f => NatM Maybe (Cxt h f a) (g (Cxt h f a)) Source #

Project the outermost layer of a term to a sub signature. If the signature g is compound of n atomic signatures, use projectn instead.

deepProject :: (HTraversable g, g :<: f) => CxtFunM Maybe f g Source #

Tries to coerce a termcontext to a termcontext over a sub-signature. If the signature g is compound of n atomic signatures, use deepProjectn instead.

Injections for Signatures and Terms

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

inject :: g :<: f => g (Cxt h f a) :-> Cxt h f a Source #

Inject a term where the outermost layer is a sub signature. If the signature g is compound of n atomic signatures, use injectn instead.

deepInject :: (HFunctor g, g :<: f) => CxtFun g f Source #

Inject a term over a sub signature to a term over larger signature. If the signature g is compound of n atomic signatures, use deepInjectn instead.

split :: f :=: (f1 :+: f2) => (f1 (Term f) :-> a) -> (f2 (Term f) :-> a) -> Term f :-> a Source #

Injections and Projections for Constants

injectConst :: (HFunctor g, g :<: f) => Const g :-> Cxt h f a Source #

projectConst :: (HFunctor g, g :<: f) => NatM Maybe (Cxt h f a) (Const g) Source #

injectCxt :: (HFunctor g, g :<: f) => Cxt h' g (Cxt h f a) :-> Cxt h f a Source #

This function injects a whole context into another context.

liftCxt :: (HFunctor f, g :<: f) => g a :-> Context f a Source #

This function lifts the given functor to a context.

substHoles :: (HFunctor f, HFunctor g, f :<: g) => (v :-> Cxt h g a) -> Cxt h' f v :-> Cxt h g a Source #

This function applies the given context with hole type a to a family f of contexts (possibly terms) indexed by a. That is, each hole h is replaced by the context f h.