compdata-0.10.1: Compositional Data Types

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

Data.Comp.Term

Description

This module defines the central notion of terms and its generalisation to contexts.

Synopsis

Documentation

data Cxt :: * -> (* -> *) -> * -> * 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 of the holes.

Constructors

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

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 Term f = Cxt NoHole f () Source

A term is a context with no holes.

type PTerm f = forall h a. Cxt h f a Source

Polymorphic definition of a term. This formulation is more natural than Term, it leads to impredicative types in some cases, though.

type Const f = f () Source

unTerm :: Cxt NoHole f a -> f (Cxt NoHole f a) Source

This function unravels the given term at the topmost layer.

simpCxt :: Functor f => f a -> Context f a Source

Convert a functorial value into a context.

toCxt :: Functor f => Term f -> Cxt h f a Source

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

constTerm :: Functor 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.