| Copyright | (c) Henry J. Wylde, 2015 |
|---|---|
| License | BSD3 |
| Maintainer | public@hjwylde.com |
| Safe Haskell | None |
| Language | Haskell2010 |
Language.Qux.Annotated.TypeChecker
Description
Type checking functions to verify that a Program is type-safe.
These functions only verify that types are used correctly. They don't verify other properties such as definite assignment.
- type Evaluation = StateT Locals (Reader Context)
- type Check = ExceptT TypeException Evaluation
- data Context
- type Locals = Map Id Type
- context :: Program -> Context
- check :: Program SourcePos -> Except TypeException ()
- checkProgram :: Program SourcePos -> Check ()
- checkDecl :: Decl SourcePos -> Check ()
- checkStmt :: Stmt SourcePos -> Check ()
- checkExpr :: Expr SourcePos -> Check Type
- checkValue :: Value -> Check Type
Environment
type Evaluation = StateT Locals (Reader Context) Source
An environment that holds the global types (Reader Context) and the local types
(Locals).
type Check = ExceptT TypeException Evaluation Source
Either a TypeException or an a.
Contains an underlying Evaluation in the monad transformer.
Contexts
Global context that holds function definition types. The function name and parameter types are held.
Type checking
Program checking
check :: Program SourcePos -> Except TypeException () Source
Type checks the program.
If an exception occurs then the result will be a TypeException, otherwise Nothing.
This function wraps checkProgram by building and evaluating the environment under
the hood.
Other node checking
checkProgram :: Program SourcePos -> Check () Source
Type checks a program.
checkValue :: Value -> Check Type Source