hindley-milner-0.1.0.0: Template for Hindley-Milner based languages

Safe HaskellSafe
LanguageHaskell2010

Language.HM.Term

Description

This module contains the abstract syntax tree of the term language.

Synopsis

Documentation

type Var = String Source

The type of variable names.

data TermF v r Source

Constructors

Var v

Variables.

App r r

Applications.

Abs v r

Abstractions.

Let v r r

Let bindings.

type Term = Fix (TermF Var) Source

The type of terms.

varE :: Var -> Term Source

varE x constructs a variable whose name is x.

appE :: Term -> Term -> Term Source

appE l r constructs an application of l to r.

absE :: Var -> Term -> Term Source

absE x e constructs an abstraction of x over e.

letE :: Var -> Term -> Term -> Term Source

letE x e0 e1 constructs a binding of e0 to x in e1.

data Typed t a Source

Things with type annotations.

Constructors

Typed 

Fields

untype :: a
 
tyAnn :: t
 

Instances

type TyVar = Typed Sigma Var Source

Typed term variables.

newtype TypedF t f r Source

Constructors

TypedF 

Fields

unTypedF :: Typed t (f r)
 

Instances

CanApply TyTerm Source 
Functor f => Functor (TypedF t f) Source 
(Show t, Show (f r)) => Show (TypedF t f r) Source 

type TyTerm = Fix (TypedF Tau (TermF TyVar)) Source

Typed terms.

tyVarE :: TyVar -> Tau -> TyTerm Source

tyVarE x t constructs a variable whose name is x and whose type is t.

tyAppE :: TyTerm -> TyTerm -> Tau -> TyTerm Source

tyAppE l r t constructs an application of l to r whose resulting type is t.

tyAbsE :: TyVar -> TyTerm -> Tau -> TyTerm Source

tyAbsE x e t constructs an abstraction of x over t whose type is t.

tyLetE :: TyVar -> TyTerm -> TyTerm -> Tau -> TyTerm Source

tyLetE x e0 e1 t constructs a binding of e0 to x in e1 whose resulting type is t.