
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An in-depth look into the tfae (tree-folding algebraic effects) type checker. It covers the grammar and data types used in the system, including te (type environment), type, and tfae expressions. The document also includes the definition of the typecheck function, which is responsible for type checking tfae expressions.
Typology: Study notes
1 / 24
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}}}}}