aboutsummaryrefslogtreecommitdiff
path: root/example.txt
diff options
context:
space:
mode:
authorCamil Staps2023-01-31 14:07:03 +0100
committerCamil Staps2023-01-31 14:07:03 +0100
commit4b7d499c3dbd5586aa855e54367d95930fd42a81 (patch)
treef4def722b898475cb191651b5cad0b5e69cd6f2f /example.txt
parentAdd compilation for symbols with arity 0 (diff)
Minor improvements; implement saturated function and constructor applications
Diffstat (limited to 'example.txt')
-rw-r--r--example.txt38
1 files changed, 23 insertions, 15 deletions
diff --git a/example.txt b/example.txt
index 38041f0..26fc2d8 100644
--- a/example.txt
+++ b/example.txt
@@ -5,13 +5,6 @@
(Cons a (List a))))
(type String (List Char))
-(fun length ((xs : List a)) : Int
- (length_acc 0 xs))
-(fun length_acc ((n : Int) (xs : List a)) : Int
- (case xs (
- (Nil -> n)
- (Cons _ xs -> length_acc (+ n 1) xs))))
-
(data TypeIdent ((TI String)))
(data TypeVarIdent ((TVI String)))
(data ConstructorIdent ((CI String)))
@@ -39,7 +32,8 @@
(CaseAlternative Pattern Expression)))
(data Expression (
- (Ident SymbolIdent)
+ (BasicValue BasicValue)
+ (Symbol SymbolIdent)
(Case Expression (List CaseAlternative))
(ExpApp Expression Expression)))
@@ -60,12 +54,26 @@
(Cons (Tuple (Cons 'n' Nil) (Type (Cons 'I' (Cons 'n' (Cons 't' Nil)))))
(Cons (Tuple (Cons 'x' (Cons 's' Nil)) (TypeApp (Type (Cons 'L' (Cons 'i' (Cons 's' (Cons 't' Nil))))) (TypeVar (Cons 'a' Nil))))
Nil))
- (Case (Ident (Cons 'x' (Cons 's' Nil)))
- (Cons (CaseAlternative (ConstructorPattern (Cons 'N' (Cons 'i' (Cons 'l' Nil))) Nil) (Ident (Cons 'n' Nil)))
- (Cons (CaseAlternative (ConstructorPattern (Cons 'C' (Cons 'o' (Cons 'n' (Cons 's' Nil)))) (Cons Wildcard (Cons (IdentPattern (Cons 'x' (Cons 's' Nil))) Nil))))
- Nil)))))
+ (Type (Cons 'I' (Cons 'n' (Cons 't' Nil))))
+ (Case (Symbol (Cons 'x' (Cons 's' Nil)))
+ (Cons (CaseAlternative
+ (ConstructorPattern (Cons 'N' (Cons 'i' (Cons 'l' Nil))) Nil)
+ (Symbol (Cons 'n' Nil)))
+ (Cons (CaseAlternative
+ (ConstructorPattern (Cons 'C' (Cons 'o' (Cons 'n' (Cons 's' Nil)))) (Cons Wildcard (Cons (IdentPattern (Cons 'x' (Cons 's' Nil))) Nil)))
+ (ExpApp (ExpApp (Symbol (Cons 'l' (Cons 'e' (Cons 'n' (Cons 'g' (Cons 't' (Cons 'h' (Cons '_' (Cons 'a' (Cons 'c' (Cons 'c' Nil))))))))))) (ExpApp (ExpApp (Cons '+' Nil) (Cons 'n' Nil)) (BasicValue (BVInt 1)))) (Cons 'x' (Cons 's' Nil))))
+ Nil)))))
+
+(#
+(fun length ((xs : List a)) : Int
+ (length_acc 0 xs))
+(fun length_acc ((n : Int) (xs : List a)) : Int
+ (case xs (
+ (Nil -> n)
+ (Cons _ xs -> length_acc (+ n 1) xs))))
+#)
-(fun testb () : Int
- 37)
+(fun testb ((x : Int) (y : Int)) : Int
+ (Tuple 37 'a'))
(fun test () : Int
- (testb))
+ (testb 37 42))