From 4ba55277a99542d245568da989b5217b04262f26 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Wed, 1 Feb 2023 21:22:23 +0100 Subject: Remove ambiguity from function definition syntax: Type (x y) could have Type as kind *->*, or (x y) could be the rhs --- example.txt | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'example.txt') diff --git a/example.txt b/example.txt index 26fc2d8..5aa858a 100644 --- a/example.txt +++ b/example.txt @@ -41,15 +41,15 @@ (DataDef TypeIdent (List TypeVarIdent) (List ConstructorDef)) (FunDef SymbolIdent (List (Tuple SymbolIdent Type)) Type Expression))) -(fun list_ast () : Definition - (DataDef +(fun list_ast () : Definition : + DataDef (Cons 'L' (Cons 'i' (Cons 's' (Cons 't' Nil)))) (Cons (Cons 'a' Nil) Nil) (Cons (ConstructorDef (Cons 'N' (Cons 'i' (Cons 'l' Nil))) Nil) (Cons (ConstructorDef (Cons 'C' (Cons 'o' (Cons 'n' (Cons 's' Nil)))) (Cons (TypeVar (Cons 'a' Nil)) (Cons (TypeApp (Type (Cons 'L' (Cons 'i' (Cons 's' (Cons 't' Nil))))) (TypeVar (Cons 'a' Nil))) Nil))) - Nil)))) -(fun length_acc_ast () : Definition - (FunDef + Nil))) +(fun length_acc_ast () : Definition : + FunDef (Cons 'l' (Cons 'e' (Cons 'n' (Cons 'g' (Cons 't' (Cons 'h' (Cons '_' (Cons 'a' (Cons 'c' (Cons 'c' Nil)))))))))) (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)))) @@ -62,18 +62,18 @@ (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))))) + Nil)))) (# -(fun length ((xs : List a)) : Int - (length_acc 0 xs)) -(fun length_acc ((n : Int) (xs : List a)) : Int - (case xs ( +(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)))) + (Cons _ xs -> length_acc (+ n 1) xs))) #) -(fun testb ((x : Int) (y : Int)) : Int - (Tuple 37 'a')) -(fun test () : Int - (testb 37 42)) +(fun testb ((x : Int) (y : Int)) : Int : + Tuple 37 'a') +(fun test () : Int : + testb 37 42) -- cgit v1.2.3