Adjust old type checker to new syntax, and refactor lambda lifter to use typed AST

This commit is contained in:
Martin Fredin 2023-02-15 23:55:16 +01:00
parent 514c809b1e
commit 210e55bb15
18 changed files with 554 additions and 145 deletions

View file

@ -1,2 +1,3 @@
f = \x. x+1;
f : Int -> Int;
f = \x:Int. x+1;

3
sample-programs/basic-10 Normal file
View file

@ -0,0 +1,3 @@
main : Int -> Int -> Int;
main x y = (x : Int) + y;

View file

@ -1,4 +1,7 @@
add x = \y. x+y;
main = (\z. z+z) ((add 4) 6);
add : Int -> Int -> Int;
add x = \y:Int. x+y;
main : Int;
main = (\z:Int. z+z) ((add 4) 6);

View file

@ -1,2 +1,3 @@
main = (\x. x+x+3) ((\x. x) 2)
main : Int;
main = (\x:Int. x+x+3) ((\x:Int. x) 2);

View file

@ -1,2 +1,7 @@
f x = let g = (\y. y+1) in g (g x)
f : Int -> Int;
f x = let
g : Int -> Int;
g = (\y:Int. y+1);
in
g (g x);

View file

@ -1,9 +1,14 @@
id : Int -> Int;
id x = x;
add : Int -> Int -> Int;
add x y = x + y;
double : Int -> Int;
double n = n + n;
apply f x = \y. f x y;
apply : (Int -> Int -> Int) -> Int -> Int -> Int;
apply f x = \y:Int. f x y;
main = apply (id add) ((\x. x + 1) 1) (double 3);
main : Int;
main = apply add ((\x:Int. x + 1) 1) (double (id 3));

View file

@ -1,3 +1,4 @@
f = \x.\y. x+y
f : Int -> Int -> Int;
f = \x:Int.\y:Int. x+y;

View file

@ -1,5 +1,8 @@
add : Int -> Int -> Int;
add x y = x + y;
apply : (Int -> Int) -> Int -> Int;
apply f x = f x;
main : Int;
main = apply (add 4) 6;

View file

@ -1,2 +1,7 @@
f x = let double = \y. y+y in (\x. x+y) 4;
f : Int -> Int;
f x = let
double : Int -> Int;
double = \y:Int. y+y
in
double (x + 4);

View file

@ -1,4 +1,5 @@
main = (\f.\x.\y. f x + f y) (\x. x+x) ((\x. x+1) ((\x. x+3) 2)) 4
main : Int;
main = (\f:Int -> Int.\x:Int.\y:Int. f x + f y) (\x:Int. x+x) ((\x:Int. x+1) ((\x:Int. x+3) 2)) 4