language-qux-0.1.0.1: Utilities for working with the Qux language

Copyright(c) Henry J. Wylde, 2015
LicenseBSD3
Maintainerpublic@hjwylde.com
Safe HaskellNone
LanguageHaskell2010

Language.Qux.Annotated.TypeChecker

Contents

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.

Synopsis

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

data Context Source

Global context that holds function definition types. The function name and parameter types are held.

type Locals = Map Id Type Source

Local context.

context :: Program -> Context Source

Returns a context for the given program.

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.

checkDecl :: Decl SourcePos -> Check () Source

Type checks a declaration.

checkExpr :: Expr SourcePos -> Check Type Source

Type checks an expression.