
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















typecheck
TypeEnv
-> Type)
(lambda
(fae^
env) (type-case
FAE^ fae [num^ (n) ...])))
typecheck
TypeEnv
-> Type)
(lambda
(fae^
env) (type-case
FAE^ fae [num^ (n) (numT)])))
typecheck
TypeEnv
-> Type)
(lambda
(fae^
env) (type-case
FAE^ fae [add^ (l r)(type-case
Type^
(typecheck
l env)
[numT^
()...^ (typecheck
r env) ...]
[else^
(type-error
l "num")])])))
typecheck
TypeEnv
-> Type)
(lambda
(fae^
env) (type-case
FAE^ fae [add^ (l r)(type-case
Type^
(typecheck
l env)
[numT^
()(type-case
Type^
(typecheck r env) [numT^
()^ (numT)] [else^
(type-error
r "num")])]
[else^
(type-error
l "num")])])))
typecheck
TypeEnv
-> Type)
(lambda
(fae^
env) (type-case
FAE^ fae [id^ (name) (get-type
name^
env)])))
typecheck
TypeEnv
-> Type)
(lambda
(fae^
env) (type-case
FAE^ fae [fun^ (name
2
typecheck
TypeEnv
-> Type)
(lambda
(fae^
env) (type-case
FAE^ fae [fun^ (name
te^ body)(local^ [(define
arg-type
(parse-type
te))]
...^ (typecheck
body^
(aBind
namearg-typeenv))
2
typecheck
TypeEnv
-> Type)
(lambda
(fae^
env) (type-case
FAE^ fae [fun^ (name
te^ body)(local^ [(define
arg-type
(parse-type
te))]
(arrowT
arg-type(typecheck
body^
(aBind name
arg-typeenv))))])))
2
typecheck
TypeEnv
-> Type)
(lambda
(fae^
env) (type-case
FAE^ fae [app^ (fn
arg)... (typecheck
fn env) ... ...^ (typecheck
arg env) ...])))
typecheck
TypeEnv
-> Type)
(lambda
(fae^
env) (type-case
FAE^ fae [app^ (fn
arg)(type-case
Type^
(typecheck
fn env)
[arrowT
(arg-type
result-type) ...^ (typecheck
arg^ env) ...]
[else^
(type-error
fn "function")])])))
{with {pair
: (num
->^ (num
->^ (num
-> num)))
{fun^ {x : num}{fun
{y : num}{fun^
{s : num}{if0^ s x y}}}}}
{with {fst
: ((num
->^ num) ->
num)
{fun^ {p : (num
->^ num)} {p 0}}} {with {snd
: ((num
->^ num) -> num) {fun^ {p : (num
->^ num)} {p 1}}} {snd^ {{pair
1} 2}}}}}
{with {pair : (bool
->^ (bool
->^ (num
-> bool)))
{fun^ {x : bool}{fun
{y : bool}{fun^
{s : num}{if0^ s x y}}}}}
{with {fst : ((num
->^ bool) ->
bool)
{fun^ {p : (num
->^ bool)} {p 0}}} {with {snd
: ((num
->^ bool) ->
bool)
{fun^ {p : (num
->^ bool)} {p 1}}} {snd {{pair
true} false}}}}}