The language is extended to support:
-
Definitions
- Simple:
def x = expr
- Sequential:
d1; d2
- Parallel:
d1 || d2
- Local Scoping:
local d1 in d2 end
- Simple:
-
Functions
- Function abstractions with one input argument -
\x. expr
- Function Call -
e1(e2)
- Function abstractions with one input argument -
-
Tuples
- n-tuple:
(a, b, ....)
- Projection (Get the ith element of an n-tuple):
Proj((i,n), e)
where 0 <= i <= n
- n-tuple:
Types for the language are defined as:
type exptype =
| Tint
| Tunit
| Tbool
| Ttuple of (exptype list) (* Tuple type *)
| Tfunc of (exptype * exptype) (* Function Abstraction Type *)
As for the type-checker for the language, we define two functions hastype
and yields
,
hastype
represents the associationG |- e : t
. The functionhastype
takes a set of type assumptionsG
(represented as a list of tuples of the form (variable name, type)), an expressione
, and an expression typet
, and decides if the expressione
has the claimed typet
under the given type assumptionsG
.
val hastype : type_assumptions -> expression -> exptype -> bool
yields
represents the associationG |- d : G'
. The functionyields
takes a set of type assumptionsG
, a definitiond
, and another set of type assumptionsG'
and decides whether under the given assumptionsG
, the definitiond
yields the type assumptionsG'
or not.
val yields: type_assumptions -> definition -> type_assumptions -> bool