| Copyright | (c) Edward Kmett and Dan Doel 2012 | 
|---|---|
| License | BSD3 | 
| Maintainer | Edward Kmett <ekmett@gmail.com> | 
| Stability | experimental | 
| Portability | non-portable (DeriveDataTypeable) | 
| Safe Haskell | None | 
| Language | Haskell2010 | 
Ermine.Syntax.Term
Contents
Description
This module provides the AST for Terms
- data Term t a
- bindTerm :: (t -> t') -> (a -> Term t' b) -> Term t a -> Term t' b
- data HardTerm
- class Terminal t where
- data BodyBound
- data WhereBound
- class AsDecl t where
- data Binding t a = Binding {- _bindingLoc :: !Rendering
- _bindingType :: !(BindingType t)
- _bindingBodies :: [Body t a]
 
- class HasBinding t t a | t -> t a where- binding :: Lens' t (Binding t a)
- bindingBodies :: Lens' t [Body t a]
- bindingLoc :: Lens' t Rendering
- bindingType :: Lens' t (BindingType t)
 
- data BindingType t
- _Implicit :: forall t. Prism' (BindingType t) ()
- _Explicit :: forall t t. Prism (BindingType t) (BindingType t) t t
- data Body t a = Body {- _bodyPatterns :: [Pattern t]
- _bodyGuarded :: Guarded (Scope BodyBound (Term t) a)
- _bodyWhere :: [Binding t (Var WhereBound a)]
 
- bodyPatterns :: forall t a. Lens' (Body t a) [Pattern t]
- bodyGuarded :: forall t a. Lens' (Body t a) (Guarded (Scope BodyBound (Term t) a))
- bodyWhere :: forall t a. Lens' (Body t a) [Binding t (Var WhereBound a)]
- bodyDecls :: Traversal' (Body t a) Word64
Terms
Terms in the Ermine language.
Constructors
| Var a | |
| App !(Term t a) !(Term t a) | |
| HardTerm !HardTerm | |
| Sig !(Term t a) t | |
| Lam [Pattern t] !(Scope PatternPath (Term t) a) | |
| Case !(Term t a) [Alt t (Term t) a] | |
| Let [Binding t a] !(Scope Word64 (Term t) a) | |
| Loc !Rendering !(Term t a) | informational link to the location the term came from | 
| Remember !Int !(Term t a) | Used to provide hole support. | 
Instances
| Show2 Term | |
| Eq2 Term | |
| Bitraversable Term | |
| Serial2 Term | |
| Bifunctor Term | |
| Bifoldable Term | |
| ((~) (* -> * -> *) p (Tagged *), (~) (* -> *) f Identity) => Tup p f (Term t a) | |
| Monad (Term t) | |
| Functor (Term t) | |
| Applicative (Term t) | |
| Foldable (Term t) | |
| Traversable (Term t) | |
| Show t => Show1 (Term t) | |
| Eq t => Eq1 (Term t) | |
| Serial t => Serial1 (Term t) | |
| App (Term t) | |
| Variable (Term t) | |
| (Eq t, Eq a) => Eq (Term t a) | |
| (Show t, Show a) => Show (Term t a) | |
| IsString a => IsString (Term t a) | |
| (Binary t, Binary v) => Binary (Term t v) | |
| (Serialize t, Serialize v) => Serialize (Term t v) | |
| (Serial t, Serial v) => Serial (Term t v) | |
| Terminal (Term t a) | |
| HasKindVars t t' k k' => HasKindVars (Term t a) (Term t' a) k k' | |
| HasTypeVars t t' tv tv' => HasTypeVars (Term t a) (Term t' a) tv tv' | 
bindTerm :: (t -> t') -> (a -> Term t' b) -> Term t a -> Term t' b Source
Perform simultaneous substitution on terms and type annotations.
Hard Terms
Simple terms that can be compared with structural equality.
This class provides a prism to match against or inject a HardTerm.
Minimal complete definition
Bindings
Bound variables in a declaration are rather complicated. One can refer
 to any of the following:
   1. Definitions in the same declaration sequence
   2. Variables bound in a pattern
   3. Definitions in a where clause
 the DeclBound type captures these three cases in the respective constructors.
data WhereBound Source
Constructors
| WhereDecl Word64 | |
| WherePat PatternPath | 
Instances
| Eq WhereBound | |
| Ord WhereBound | |
| Read WhereBound | |
| Show WhereBound | |
| Generic WhereBound | |
| Binary WhereBound | |
| Serialize WhereBound | |
| Serial WhereBound | |
| AsDecl WhereBound | |
| type Rep WhereBound | 
Minimal complete definition
Nothing
Instances
A Binding provides its source location as a rendering, knowledge of if it is explicit or implicitly bound and a list of right hand side bindings.
Constructors
| Binding | |
| Fields 
 | |
Instances
| Bitraversable Binding | |
| Serial2 Binding | |
| Bifunctor Binding | |
| Bifoldable Binding | |
| Functor (Binding t) | |
| Foldable (Binding t) | |
| Traversable (Binding t) | |
| Serial t => Serial1 (Binding t) | |
| (Eq t, Eq a) => Eq (Binding t a) | |
| (Show t, Show a) => Show (Binding t a) | |
| (Binary t, Binary v) => Binary (Binding t v) | |
| (Serial t, Serial v) => Serial (Binding t v) | |
| HasBinding (Binding t a) t a | 
class HasBinding t t a | t -> t a where Source
Minimal complete definition
Methods
binding :: Lens' t (Binding t a) Source
bindingBodies :: Lens' t [Body t a] Source
bindingLoc :: Lens' t Rendering Source
bindingType :: Lens' t (BindingType t) Source
Instances
| HasBinding (Binding t a) t a | 
data BindingType t Source
Indicate if a definition is explicitly bound with a type annotation or implicitly bound without.
Instances
| Functor BindingType | |
| Foldable BindingType | |
| Traversable BindingType | |
| Serial1 BindingType | |
| Eq t => Eq (BindingType t) | |
| Show t => Show (BindingType t) | |
| Generic (BindingType t) | |
| Binary t => Binary (BindingType t) | |
| Serialize t => Serialize (BindingType t) | |
| Serial t => Serial (BindingType t) | |
| type Rep (BindingType t) | 
_Implicit :: forall t. Prism' (BindingType t) () Source
_Explicit :: forall t t. Prism (BindingType t) (BindingType t) t t Source
A body is the right hand side of a definition. This isn't a term because it has to perform simultaneous matches on multiple patterns with backtracking. Each Body contains a list of where clause bindings to which the body and guards can refer.
Constructors
| Body | |
| Fields 
 | |
Instances
| Bitraversable Body | |
| Serial2 Body | |
| Bifunctor Body | |
| Bifoldable Body | |
| Functor (Body t) | |
| Foldable (Body t) | |
| Traversable (Body t) | |
| Serial t => Serial1 (Body t) | |
| (Eq t, Eq a) => Eq (Body t a) | |
| (Show t, Show a) => Show (Body t a) | |
| (Binary t, Binary a) => Binary (Body t a) | |
| (Serialize t, Serialize a) => Serialize (Body t a) | |
| (Serial t, Serial v) => Serial (Body t v) | 
bodyPatterns :: forall t a. Lens' (Body t a) [Pattern t] Source
bodyWhere :: forall t a. Lens' (Body t a) [Binding t (Var WhereBound a)] Source