compdata-0.11: 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.Term

Description

This module defines the central notion of mutual recursive (or, higher-order) terms and its generalisation to (higher-order) contexts. All definitions are generalised versions of those in Data.Comp.Term.

Synopsis

Documentation

data Cxt h f a i where Source #

This data type represents contexts over a signature. Contexts are terms containing zero or more holes. The first type parameter is supposed to be one of the phantom types Hole and NoHole. The second parameter is the signature of the context. The third parameter is the type family of the holes. The last parameter is the index/label.

Constructors

Term :: f (Cxt h f a) i -> Cxt h f a i 
Hole :: a i -> Cxt Hole f a i 

Instances

HFunctor f => HFunctor (Cxt h f) Source # 

Methods

hfmap :: (f :-> g) -> Cxt h f f :-> Cxt h f g Source #

HFoldable f => HFoldable (Cxt h f) Source # 

Methods

hfold :: Monoid m => Cxt h f (K m) :=> m Source #

hfoldMap :: Monoid m => (a :=> m) -> Cxt h f a :=> m Source #

hfoldr :: (a :=> (b -> b)) -> b -> Cxt h f a :=> b Source #

hfoldl :: (b -> a :=> b) -> b -> Cxt h f a :=> b Source #

hfoldr1 :: (a -> a -> a) -> Cxt h f (K a) :=> a Source #

hfoldl1 :: (a -> a -> a) -> Cxt h f (K a) :=> a Source #

HTraversable f => HTraversable (Cxt h f) Source # 

Methods

hmapM :: Monad m => NatM m a b -> NatM m (Cxt h f a) (Cxt h f b) Source #

htraverse :: Applicative f => NatM f a b -> NatM f (Cxt h f a) (Cxt h f b) Source #

EqHF f => EqHF (Cxt h f) Source # 

Methods

eqHF :: KEq g => Cxt h f g i -> Cxt h f g j -> Bool Source #

(HFunctor f, OrdHF f) => OrdHF (Cxt h f) Source #

From an OrdHF difunctor an Ord instance of the corresponding term type can be derived.

Methods

compareHF :: KOrd a => Cxt h f a i -> Cxt h f a j -> Ordering Source #

(EqHF f, KEq a) => KEq (Cxt h f a) Source # 

Methods

keq :: Cxt h f a i -> Cxt h f a j -> Bool Source #

(HFunctor f, OrdHF f, KOrd a) => KOrd (Cxt h f a) Source # 

Methods

kcompare :: Cxt h f a i -> Cxt h f a j -> Ordering Source #

data Hole Source #

Phantom type that signals that a Cxt might contain holes.

data NoHole Source #

Phantom type that signals that a Cxt does not contain holes.

type Context = Cxt Hole Source #

A context might contain holes.

type Term f = Cxt NoHole f (K ()) Source #

A (higher-order) term is a context with no holes.

type Const f = f (K ()) Source #

constTerm :: HFunctor f => Const f :-> Term f Source #

This function converts a constant to a term. This assumes that the argument is indeed a constant, i.e. does not have a value for the argument type of the functor f.

unTerm :: Term f t -> f (Term f) t Source #

This function unravels the given term at the topmost layer.

toCxt :: HFunctor f => Term f :-> Context f a Source #

Cast a term over a signature to a context over the same signature.

simpCxt :: HFunctor f => f a i -> Context f a i Source #