|
|
|
|
|
|
Synopsis |
|
|
|
|
Types |
|
data Type |
The type of a variable (with 'absint' ordering). | Constructors | TypeLabel | A variable that will be bound to labels, only. | TypeTerm | A variable that can be bound to any term. |
| Instances | |
|
|
data Def |
While pattern matching, the definition state of a variable.
Used to spot doubly defined variables ( malformed patterns as f(X,X) ). | Constructors | Defined | Variable was defined by an earlier match. | Defining | Variable was defined by the current match. |
|
|
|
data TypeEnv |
The state holding all the information about variables and term heads. | Constructors | |
|
|
State of the Typechecker |
|
type TypeSt = StateT TypeEnv TypeCheckResult |
The actual state monad. Represents a computation having a TypeEnv as a
state, but that can fail with a TypeError. |
|
forgetVariables :: TypeSt () |
Forget all about variables (but remember term heads information) |
|
fixVariables :: TypeSt () |
Make Defining variables become Defined. |
|
checkHead :: Head -> Int -> TypeSt () |
Check a term Head.
- If already known, but the arity disagrees, fail.
- Otherwise, remember the arity.
|
|
checkVar :: Variable -> Type -> TypeSt () |
Check a Variable occurring in a pattern.
- If already known, but is not Defined or the type does not match, fail.
- Otherwise, mark it as Defining and remember the type.
|
|
definingVar :: Variable -> TypeSt () |
Define a Variable using TypeTerm and Defining. Do not perform any
check. |
|
useVar :: Variable -> TypeSt () |
If a variable is not Defined, fail. |
|
Checking the Goal (Clause head) |
|
checkGoalTerm :: Term -> TypeSt () |
Check the goal Term. |
|
checkGoal :: Clause -> TypeSt () |
Check a goal. |
|
Checking FullRules |
|
checkToplevelPattern :: Term -> TypeSt () |
Check the toplevel pattern of a FullRule. |
|
checkInnerPattern :: Term -> Term -> TypeSt () |
Check a pattern that was inside a f(-) context in a FullRule. |
|
checkClause :: Clause -> TypeSt () |
Check a FullRule Clause. |
|
checkFullRule :: Rule -> TypeSt () |
|
Checking SimpleRules |
|
checkSimplePattern :: Term -> TypeSt () |
Check the pattern inside a SimpleRule. |
|
checkSimpleRule :: Rule -> TypeSt () |
Check a SimpleRule for arity consistency, and undefined variables. |
|
Main Routines. |
|
typeCheckRules :: [Rule] -> [Rule] -> TypeSt () |
Check SimpleRules and FullRules, |
|
typeCheckGrammar :: [(Label, [Term])] -> TypeSt () |
Check for arity consistency. |
|
typeCheckRulesAndGrammar :: [Rule] -> [Rule] -> [(Label, [Term])] -> Maybe (Rule, TypeError) |
The main type checking routine. Return Nothing on success.
On error, the Rule premiss is empty iff the error was in the grammar. |
|
Type Errors |
|
data TypeError |
Constructors | TermTooDeep Term | Maximum term depth is one in FullRules. | LabelRequired Variable | A label or a label-valued variable was
expected. | MultipleArity Head Int Int | Term head with two distinct arities found. | MultipleDef Variable | A pattern defined a variable more than once. | NoDef Variable | A variable occurs only in the goal. |
|
|
|
data TypeCheckResult a |
A simple error monad that propagates errors. | Constructors | TypeCheck a | Type check succeded. | TypeError Rule TypeError | Type check failed for a rule. |
| Instances | |
|
|
typeErrorMsg :: Rule -> TypeError -> String |
User-friendly error messages. |
|
Utilities |
|
typeError :: TypeError -> TypeSt () |
Smart constructor. |
|
setRuleOnError :: Rule -> TypeSt a -> TypeSt a |
|
setProductionOnError :: Label -> Term -> TypeSt a -> TypeSt a |
|
Produced by Haddock version 0.6 |