Add lazy mode tests, update normal tests

This commit is contained in:
LunaAmora 2024-02-02 13:44:06 -03:00
parent 9c3aa73b75
commit 51dcee3fbd
129 changed files with 942 additions and 24 deletions

View File

@ -0,0 +1 @@
(main) = (λx (+ (+ 1 1) x) 8)

View File

@ -0,0 +1,13 @@
data Opt = (Some x) | None
Opt.map = @opt @f
match opt {
Some: (Some (f opt.x));
None: None
}
inc = @x (+ x 1)
main =
let opt = (Some 1);
(Opt.map opt inc)

View File

@ -0,0 +1,3 @@
data Option = (Some val) | None
main = λa #Option (a #wrong_tag λb b *)

View File

@ -0,0 +1,11 @@
data Option = (Some val) | None
Option.and = @a @b match a {
Some: match b {
Some: (Some (a.val, b.val))
None: None
}
None: None
}
main = Option.and

View File

@ -0,0 +1,3 @@
data Option = (Some val) | None
main = (@a #Option (a #wrong_tag @x x *))

View File

@ -0,0 +1,6 @@
data bool = true | false
and a false = false
and a true = a
main = (and true false)

View File

@ -0,0 +1,45 @@
data Tree = (Leaf a) | (Both a b)
data Error = Err
// Atomic Swapper
(Swap n a b) = match n {
0: (Both a b)
+: (Both b a)
}
// Swaps distant values in parallel; corresponds to a Red Box
(Warp s (Leaf a) (Leaf b)) = (Swap (^ (> a b) s) (Leaf a) (Leaf b))
(Warp s (Both a b) (Both c d)) = (Join (Warp s a c) (Warp s b d))
(Warp s a b) = Err
// Rebuilds the warped tree in the original order
(Join (Both a b) (Both c d)) = (Both (Both a c) (Both b d))
(Join a b) = Err
// Recursively warps each sub-tree; corresponds to a Blue/Green Box
(Flow s (Leaf a)) = (Leaf a)
(Flow s (Both a b)) = (Down s (Warp s a b))
// Propagates Flow downwards
(Down s (Leaf a)) = (Leaf a)
(Down s (Both a b)) = (Both (Flow s a) (Flow s b))
// Bitonic Sort
(Sort s (Leaf a)) = (Leaf a)
(Sort s (Both a b)) = (Flow s (Both (Sort 0 a) (Sort 1 b)))
// Generates a tree of depth `n`
(Gen n x) = match n {
0: (Leaf x)
+: (Both (Gen n-1 (* x 2)) (Gen n-1 (+ (* x 2) 1)))
}
// Reverses a tree
(Rev (Leaf x)) = (Leaf x)
(Rev (Both a b)) = (Both (Rev b) (Rev a))
// Sums a tree
(Sum (Leaf x)) = x
(Sum (Both a b)) = (+ (Sum a) (Sum b))
Main = (Sum (Sort 0 (Rev (Gen 4 0))))

View File

@ -0,0 +1,59 @@
// data Tree = (Leaf x) | (Node x0 x1)
Leaf = λx #Tree λl #Tree λn (l x)
Node = λx0 λx1 #Tree λl #Tree λn (n x0 x1)
swap = λn match n {
0: λx0 λx1 (Node x0 x1)
+: λx0 λx1 (Node x1 x0)
}
warp = λa
let a_leaf = λax λb
let b_leaf = λbx λax λs (swap (^ (> ax bx) s) (Leaf ax) (Leaf bx))
let b_node = λa0 λa1 λax λs 0
(#Tree (b b_leaf b_node) ax)
let a_node = λa0 λa1 λb
let b_leaf = λbx λa0 λa1 λs 0
let b_node = λb0 λb1 λa0 λa1 λs (join (warp a0 b0 s) (warp a1 b1 s))
(#Tree (b b_leaf b_node) a0 a1)
#Tree (a a_leaf a_node)
join = λa
let a_leaf = λax λb 0
let a_node = λa0 λa1 λb
let b_leaf = λbx λa0 λa1 0
let b_node = λb0 λb1 λa0 λa1 (Node (Node a0 b0) (Node a1 b1))
(#Tree (b b_leaf b_node) a0 a1)
#Tree (a a_leaf a_node)
flow = λa
let a_leaf = λax λs (Leaf ax)
let a_node = λa0 λa1 λs (down (warp a0 a1 s) s)
#Tree (a a_leaf a_node)
down = λa
let a_leaf = λax λs (Leaf ax)
let a_node = λa0 λa1 λs (Node (flow a0 s) (flow a1 s))
#Tree (a a_leaf a_node)
sort = λa
let a_leaf = λax λs (Leaf ax)
let a_node = λa0 λa1 λs (flow (Node (sort a0 0) (sort a1 1)) s)
#Tree (a a_leaf a_node)
gen = λn match n {
0: λx (Leaf x)
+: λx (Node (gen n-1 (* x 2)) (gen n-1 (+ (* x 2) 1)))
}
rev = λa
let a_leaf = λax (Leaf ax)
let a_node = λa0 λa1 (Node (rev a1) (rev a0))
#Tree (a a_leaf a_node)
sum = λa
let a_leaf = λax ax
let a_node = λa0 λa1 (+ (sum a0) (sum a1))
#Tree (a a_leaf a_node)
main = (sum (sort (rev (gen 8 0)) 0))

View File

@ -0,0 +1,7 @@
data _Box = (Box val)
Box.subst (Box n) from to = (Box.subst.go n (== from n) to)
Box.subst.go a 0 to = (Box a)
Box.subst.go a +* to = to
Main = (Box.subst (Box 4) 4 (Box 10))

View File

@ -0,0 +1,7 @@
data _Box = (Box val)
Box.subst (Box n) from to = (Box.subst.go n (== from n) to)
Box.subst.go a 0 to = (Box a)
Box.subst.go a +* to = to
Main = (Box.subst (Box 4) 8000 (Box 10))

View File

@ -0,0 +1,8 @@
(CC.lang program) =
let callcc = λcallback (λ$garbage($hole) (callback λ$hole(0)))
let result = (program callcc)
let garbage = $garbage
result
Main = (CC.lang λcallcc
(+ 10 (callcc λk(+ (k 42) 1729))))

View File

@ -0,0 +1 @@
main = (SCons '\u1234' (SCons '!' (SCons '7' SNil)))

View File

@ -0,0 +1,3 @@
go (a, (b, (c, (d, e)))) = (+ (+ (+ (+ e d) c) b) a)
main = (go (1, (2, (3, (4, 5)))))

View File

@ -0,0 +1 @@
(main) = let {x1 x2} = $a; ((λ$a λb b) (x1 x2))

View File

@ -0,0 +1,2 @@
Id = λb b
main = λa (Id a)

View File

@ -0,0 +1,84 @@
// Write definitions like this
(Def1) = ((λa a) (λb b))
// You can call a definition by just referencing its name
// It will be substituted in place of the reference
(Def2) = ((λa a) Def1)
// Definitions and variables can have names in upper and lower case and contain numbers
// Names defined in a more inner position shadow names in an outer position
(def3) = ((λDef1 Def1) (λx λx x))
// The language is affine, but if you use a variable more than once the compiler inserts duplications for you
// Of course you can always do them manually
(def4) = λz let {z1 z2} = z; (z1 ((λx (x x x x x)) z2))
// You can use machine numbers and some native numeric operations
// Numeric operations can only reduce numbers, doing (+ (λx x) 1) will not do anything
(nums) = λx1 λx2 (* (+ x1 1) (/ (- x2 2) 1))
// You can use numbers on the native match expression
// The `+` arm binds the `scrutinee`-1 variable to the the value of the number -1
(Num.pred) = λn
match n {
0: 0
+: n-1
}
// Write new data types like this
data Option = (Some val) | None
data Bool = True | False
// You can have pattern matching on definitions
// Use `*` to ignore a pattern
(Option.unwrap_or (Some val) *) = val
(Option.unwrap_or None or) = or
(Bool.or True *) = True
(Bool.or * True) = True
(Bool.or * *) = False
// Or using a match expression
(Bool.not) = λbool
match bool {
True: False
False: True
}
// Data types can store values
data Boxed = (Box val)
// Types with only one constructor can be destructured using `let` or a single matching definition
(Box.map (Box val) f) = (Box (f val))
(Box.unbox) = λbox
let (Box val) = box
val
// Use tuples to store two values together without needing to create a new data type
(Tuple.new fst snd) =
let pair = (fst, snd)
pair
// Then you can destructure it inside the definition or using `let`
(Tuple.fst (fst, snd)) = fst
(Tuple.snd) = λpair
let (fst, snd) = pair
snd
// All files must have a main definition to be run.
// You can execute a program in HVM with "cargo run -- --run <path to file>"
// Other options are "--check" (the default mode) to just see if the file is well formed
// and "--compile" to output hvm-core code.
(main) =
let tup = (Tuple.new None (Num.pred 5))
let fst = (Tuple.fst tup)
let snd = (Tuple.snd tup)
let box = (Box fst)
let map = (Box.map box Option.unwrap_or)
let unboxed = ((Box.unbox map) snd)
(nums 3 unboxed)

View File

@ -0,0 +1 @@
main = ((λfλx (f (f x))) (λfλx (f (f x))))

View File

@ -0,0 +1,5 @@
// We expect the lambda 'p' from the match to be extracted which allows this recursive func
val = λn (match n { 0: valZ; +: (valS n-1) })
valZ = 0
valS = λp (val p)
main = (val 1)

View File

@ -0,0 +1,28 @@
data Box = (New a)
data Bool = T | F
data List_ = (Cons x xs) | Nil
data Pair = (Tup a b)
(Tup.and (Tup (New T) (New T))) = T
(Tup.and (Tup a b)) = F
(Not T) = F
(Not F) = T
main = (Not
(Tup.and
(Cons
(Tup (New T) (New F))
(Cons
(Tup (New F) (New F))
(Cons
(Tup (New T) (New T))
(Cons
(Tup (New F) (New T))
Nil
)
)
)
)
)
)

View File

@ -0,0 +1 @@
main = λx (+ x 2)

View File

@ -0,0 +1,7 @@
/*
main = λx (+ (* x x) (+ (+ 2 x) 3))
FIXME: panicked at 'not yet implemented' on hvmc::run::NetFields `if next.is_op1() { todo!(); } // FIXME`
*/
main = *

View File

@ -0,0 +1 @@
main = λa let (x1, x2) = a; (x1 x2)

View File

@ -0,0 +1,4 @@
main = @a @b let c = (+ a a); match a {
0: b;
+: (+ a-1 b);
}

View File

@ -0,0 +1 @@
Main = (LCons 42 (LCons (LCons @x x LNil) LNil))

View File

@ -0,0 +1,9 @@
data list = (cons h t) | nil
reverse (cons h t) = (concat (reverse t) (cons h nil))
reverse nil = nil
concat (cons h t) x = (cons h (concat t x))
concat nil x = x
main = (reverse (cons 3 (cons 2 (cons 1 nil))))

View File

@ -0,0 +1,9 @@
Take_ n list =
match (== n 0) {
| 0: (Take n list)
| +: []
}
Take n (LNil) = []
Take n (LCons x xs) = (LCons x (Take_ (- n 1) xs))
main = (Take 2 [3, 2, 1, 5, 5, 5])

View File

@ -0,0 +1,29 @@
List.len list = (List.len.go list 0)
List.len.go [] count = count
List.len.go (LCons x xs) count = (List.len.go xs (+ count 1))
Take.go n list =
match (== n 0) {
| 0: (Take n list)
| +: []
}
Take n [] = []
Take n (LCons x xs) = (LCons x (Take.go (- n 1) xs))
Drop.go n list =
match (== n 0) {
| 0: (Drop n list)
| +: list
}
Drop n [] = []
Drop n (LCons x xs) = (Drop.go (- n 1) xs)
List.toTree [] = *
List.toTree [x] = x
List.toTree xs =
let half = (/ (List.len xs) 2);
let x = (Take half xs);
let y = (Drop half xs);
((List.toTree x), (List.toTree y))
Main = (List.toTree [1, 2, 3, 4, 5])

View File

@ -0,0 +1,5 @@
main =
match (+ 0 1) {
0: λt λf t
+: λt λf f
}

View File

@ -0,0 +1,4 @@
Bar [(SCons x xs), y] = (xs, y)
Bar * = []
Main = (Bar ["hello", "world"])

View File

@ -0,0 +1,4 @@
main = @a @b @c @d match a {
0: (+ (+ b c) d);
+: (+ (+ (+ a-1 b) c) d);
}

View File

@ -0,0 +1,6 @@
pred = @n match n {
0: 0
+: n-1
}
main = (pred 4)

View File

@ -0,0 +1,27 @@
data Tree = (Leaf x) | (Node x0 x1)
data List_ = Nil | (Cons h t)
sort (Leaf v) = (Cons v Nil)
sort (Node a b) = (merge (sort a) (sort b))
merge (Nil) b = b
merge (Cons x xs) (Nil) = (Cons x xs)
merge (Cons x xs) (Cons y ys) =
let t = match (< x y) {
0: λaλbλcλt(t c a b)
+: λaλbλcλt(t a b c)
}
let t = (t (Cons x) λx(x) (Cons y))
(t λa λb λc (a (merge (b xs) (c ys))))
sum Nil = 0
sum (Cons h t) = (+ h (sum t))
range n = match n {
0: λx (Leaf x)
+: λx (Node (range n-1 (+ (* x 2) 1)) (range n-1 (* x 2)))
}
main = (sum (sort (range 4 0)))

View File

@ -0,0 +1,6 @@
main =
let (a, (b, c)) =
let (i, (j, k)) = (10, ((1, ((2, 3), 4)), 3));
j;
let (x, y) = b;
x

View File

@ -0,0 +1 @@
main = @a [a, (*, 2), (SCons [7, "1234", 9] (SCons a (SCons * (SCons '4' (SCons '2' SNil)))))]

View File

@ -0,0 +1,6 @@
Main = (
(SCons "a" SNil),
(SCons 'a' (SCons "bc" SNil)),
(SCons "ab" (SCons 'c' SNil)),
(SCons "ab" (SCons "cd" SNil))
)

View File

@ -0,0 +1,4 @@
Pred 0 = 0
Pred +pred = pred
Main = (Pred 43)

View File

@ -0,0 +1,24 @@
// A cool trick involving HVM's scopeless lambdas is linear qs:
// Qnew : Queue a
Qnew = λx x
// Qadd : a -> Queue a -> Queue a
Qadd = λx λq λk (q λc (c x k))
// Qrem : Queue a -> Pair a (Queue a)
Qrem = λq (q $k λx λxs λp(p x λ$k xs))
Nil = λc λn n
Cons = λh λt λc λn (c h t)
// Output: [1, 2, 3]
main =
let q = Qnew
let q = ((Qadd) 1 q)
let q = ((Qadd) 2 q)
let q = ((Qadd) 3 q)
(((Qrem) q) λv0 λq
(((Qrem) q) λv1 λq
(((Qrem) q) λv2 λq
((Cons) 1 ((Cons) 2 ((Cons) 3 Nil))))))

View File

@ -0,0 +1,85 @@
data Map = Free | Used | (Both a b)
data Arr = Null | (Leaf x) | (Node a b)
(Swap s a b) = match s {
0: (Both a b)
+: (Both b a)
}
// Sort : Arr -> Arr
(Sort t) = (ToArr 0 (ToMap t))
// ToMap : Arr -> Map
(ToMap Null) = Free
(ToMap (Leaf a)) = (Radix a)
(ToMap (Node a b)) = (Merge (ToMap a) (ToMap b))
// ToArr : U60 -> Map -> Arr
(ToArr x Free) = Null
(ToArr x Used) = (Leaf x)
(ToArr x (Both a b)) =
let a = (ToArr (+ (* x 2) 0) a)
let b = (ToArr (+ (* x 2) 1) b)
(Node a b)
// Merge : Map -> Map -> Map
(Merge Free Free) = Free
(Merge Free Used) = Used
(Merge Used Free) = Used
(Merge Used Used) = Used
(Merge Free (Both c d)) = (Both c d)
(Merge (Both a b) Free) = (Both a b)
(Merge (Both a b) (Both c d)) = (Both (Merge a c) (Merge b d))
(Merge (Both a b) Used) = *
(Merge Used (Both a b)) = *
// Radix : U60 -> Map
(Radix n) =
let r = Used
let r = (Swap (& n 1) r Free)
let r = (Swap (& n 2) r Free)
let r = (Swap (& n 4) r Free)
let r = (Swap (& n 8) r Free)
let r = (Swap (& n 16) r Free)
let r = (Swap (& n 32) r Free)
let r = (Swap (& n 64) r Free)
let r = (Swap (& n 128) r Free)
let r = (Swap (& n 256) r Free)
let r = (Swap (& n 512) r Free)
let r = (Swap (& n 1024) r Free)
let r = (Swap (& n 2048) r Free)
let r = (Swap (& n 4096) r Free)
let r = (Swap (& n 8192) r Free)
let r = (Swap (& n 16384) r Free)
let r = (Swap (& n 32768) r Free)
let r = (Swap (& n 65536) r Free)
let r = (Swap (& n 131072) r Free)
let r = (Swap (& n 262144) r Free)
let r = (Swap (& n 524288) r Free)
let r = (Swap (& n 1048576) r Free)
let r = (Swap (& n 2097152) r Free)
let r = (Swap (& n 4194304) r Free)
let r = (Swap (& n 8388608) r Free)
r
// Reverse : Arr -> Arr
(Reverse Null) = Null
(Reverse (Leaf a)) = (Leaf a)
(Reverse (Node a b)) = (Node (Reverse b) (Reverse a))
// Sum : Arr -> U60
(Sum Null) = 0
(Sum (Leaf x)) = x
(Sum (Node a b)) = (+ (Sum a) (Sum b))
// Gen : U60 -> Arr
(Gen n) = (Gen.go n 0)
(Gen.go n x) = match n {
0: (Leaf x)
+:
let x = (<< x 1)
let y = (| x 1)
(Node (Gen.go n-1 x) (Gen.go n-1 y))
}
Main = (Sum (Sort (Reverse (Gen 4))))

View File

@ -0,0 +1,8 @@
add = λa λb (+ a b)
sum = λn match n {
0: 1
+: (add (sum n-1) (sum n-1))
}
main = (sum 9)

View File

@ -0,0 +1,3 @@
main =
let * = λ$x 1
(2, $x)

View File

@ -0,0 +1,4 @@
concat (SNil) str = str
concat (SCons c rest1) str2 = (SCons c (concat rest1 str2))
main = (concat "hello " "world")

View File

@ -0,0 +1,9 @@
(StrInc (len, buf)) = (len, #str λx (StrGo len #str (buf x)))
(StrGo 0 str) = str
(StrGo +x (head, tail)) = ((+ 1 head), (StrGo x tail))
// Old str encoding
Hello = (11, #str λx (104, (101, (108, (108, (111, (32, (119, (111, (114, (108, (100, x))))))))))))
main = (StrInc Hello)

View File

@ -0,0 +1,9 @@
(StrInc (len, buf)) = (len, #str λx (StrGo len #str (buf x)))
(StrGo 0 (head, tail)) = (head, tail)
(StrGo +x (head, tail)) = ((+ 1 head), (StrGo x tail))
// Old str encoding
Hello = (11, #str λx (104, (101, (108, (108, (111, (32, (119, (111, (114, (108, (100, x))))))))))))
main = (StrInc Hello)

View File

@ -0,0 +1,5 @@
String.len s = (String.len.go s 0)
String.len.go (SNil) x = x
String.len.go (SCons hd tl) x = (String.len.go tl (+ x 1))
main = (String.len "λx 🐼")

View File

@ -0,0 +1,16 @@
data Tree = (Leaf x) | (Node x0 x1)
add = λa λb (+ a b)
gen = λn match n {
0: (Leaf 1)
+: (Node (gen n-1) (gen n-1))
}
sum = λt
match t {
Leaf: t.x
Node: (add (sum t.x0) (sum t.x1))
}
main = (sum (gen 8))

View File

@ -0,0 +1 @@
main = (#id {(λx x) (λx x)} 3)

View File

@ -0,0 +1 @@
main = λa let #s {b c} = a; #s {b c}

View File

@ -0,0 +1,18 @@
data N = (S pred) | Z
data B = T | F
(Not T) = F
(Not F) = T
(IsEven n) =
match n {
S: (Not (IsEven n.pred))
Z: T
}
N0 = Z
N1 = (S N0)
N2 = (S N1)
N3 = (S N2)
Main = (IsEven {{N0 N1} {N2 N3}})

View File

@ -0,0 +1 @@
main = #foo ((#foo @x (+ x 1), #foo @x (* x x)) 2)

View File

@ -0,0 +1 @@
main = λa let (b, c) = a; (b, c)

View File

@ -0,0 +1,10 @@
MkTup8 = @a @b @c @d @e @f @g @h @MkTup8 (MkTup8 a b c d e f g h)
rot = λx (x λa λb λc λd λe λf λg λh (MkTup8 b c d e f g h a))
app = λn match n {
0: λf λx x
+: λf λx (app n-1 f (f x))
}
main = (app 100 rot (MkTup8 1 2 3 4 5 6 7 8))

View File

@ -0,0 +1 @@
main = λa λb (SCons a (SCons 'b' (SCons 'c' (SCons b SNil))))

View File

@ -0,0 +1,7 @@
X = λx x
// This leaves (b1 X) with an ERA in the return, but the DUP is kept with an unused var
main = (
(λa λb let {b1 b2} = b; (a (b1 X) (b2 X)))
(λa λb b)
)

View File

@ -0,0 +1 @@
main = (SCons '\U1F30E' SNil)

View File

@ -0,0 +1 @@
Main = (SCons (*, 4) (SCons * SNil))

View File

@ -3,5 +3,5 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/unused_dup_var_linearization.hvm
---
@main = a
& (b b) ~ {0 * {0 {0 c *} {0 (c a) *}}}
& (b b) ~ {3 * {5 {9 c *} {7 (c a) *}}}

View File

@ -2,7 +2,7 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/ex0.hvm
---
@C_2 = ({0 (a b) (c a)} (c b))
@C_2 = ({3 (a b) (c a)} (c b))
@S = (a ((a b) (* b)))
@Z = (* (a a))
@main = a

View File

@ -5,7 +5,7 @@ input_file: tests/golden_tests/compile_file_o_all/ex2.hvm
@E = (* @J)
@I = (a (* ((a b) (* b))))
@J = (* (a a))
@c2 = ({0 (a b) (c a)} (c b))
@c2 = ({3 (a b) (c a)} (c b))
@decO = ((@decO (@low (@E a))) (* ((a b) (* b))))
@low = ((@lowO (@lowI (@E a))) a)
@lowI = (a (((* ((a b) (* b))) c) (* (* c))))

View File

@ -7,22 +7,22 @@ input_file: tests/golden_tests/compile_file_o_all/list_merge_sort.hvm
@Map = ({4 @P {4 @N a}} a)
@N = (* @Nil)
@Nil = {4 * {4 a a}}
@P = {8 a {6 {4 @P {4 @N (b c)}} ({0 (a d) b} {4 {8 d {6 c e}} {4 * e}})}}
@P = {8 a {6 {4 @P {4 @N (b c)}} ({3 (a d) b} {4 {8 d {6 c e}} {4 * e}})}}
@Pure = (a {4 {8 a {6 @Nil b}} {4 * b}})
@U = {8 a {6 {4 @m {4 @i (b (a c))}} (b c)}}
@V = (* @Nil)
@W = (a ({4 @U {4 @V (a b)}} b))
@Z = {8 a {6 {4 @s {4 @t (b (a c))}} (b c)}}
@a = (* @Nil)
@f = {8 {0 a {0 b c}} {6 {0 d {4 @f {4 @g (e (f (g h)))}}} ({0 (i (a {2 @J {2 @K ({4 {8 j {6 k l}} {4 * l}} ({4 {8 c {6 h m}} {4 * m}} n))}})) {0 o e}} ({0 i {0 j f}} ({0 {4 @h {4 @i (o ({4 {8 b {6 d p}} {4 * p}} k))}} g} n)))}}
@f = {8 {15 a {17 b c}} {6 {19 d {4 @f {4 @g (e (f (g h)))}}} ({5 (i (a {2 @J {2 @K ({4 {8 j {6 k l}} {4 * l}} ({4 {8 c {6 h m}} {4 * m}} n))}})) {7 o e}} ({9 i {11 j f}} ({13 {4 @h {4 @i (o ({4 {8 b {6 d p}} {4 * p}} k))}} g} n)))}}
@g = (* @w)
@h = {8 a {6 b (c ({4 @f {4 @g (c (a (b d)))}} d))}}
@i = (* (a a))
@m = {8 a {6 {4 @Z {4 @a (b {4 @m {4 @i (c (d e))}})}} ({0 c {0 f b}} ({4 @h {4 @i (f (a d))}} e))}}
@m = {8 a {6 {4 @Z {4 @a (b {4 @m {4 @i (c (d e))}})}} ({21 c {23 f b}} ({4 @h {4 @i (f (a d))}} e))}}
@main = (a (b c))
& @W ~ (a (d c))
& @Map ~ (b (@Pure d))
@s = {8 a {6 {4 @Z {4 @a (b c)}} ({0 d b} ({4 @h {4 @i (d (a e))}} {4 {8 e {6 c f}} {4 * f}}))}}
@s = {8 a {6 {4 @Z {4 @a (b c)}} ({23 d b} ({4 @h {4 @i (d (a e))}} {4 {8 e {6 c f}} {4 * f}}))}}
@t = (* @x)
@w = (a (b {4 {8 a {6 b c}} {4 * c}}))
@x = (a {4 {8 a {6 @Nil b}} {4 * b}})

View File

@ -4,7 +4,7 @@ input_file: tests/golden_tests/compile_file_o_all/match_dup_and_reconstruction.h
---
@A = {4 a (b [b a])}
@Boxed = (a {2 {4 a b} b})
@Got = ({0 {2 @A (a b)} a} b)
@Got = ({3 {2 @A (a b)} a} b)
@main = a
& @Got ~ (b a)
& @Boxed ~ (#10 b)

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/recursive_combinator_inactive.hvm
---
@7 = (a (* a))
@Foo = (?<({0 @Foo @Foo} @7) a> a)
@Foo = (?<({3 @Foo @Foo} @7) a> a)
@main = a
& @Foo ~ (#0 a)

View File

@ -6,7 +6,7 @@ input_file: tests/golden_tests/compile_file_o_all/scrutinee_reconstruction.hvm
@C = {4 * @E}
@E = (a (* a))
@None = {2 * {2 a a}}
@Option.or = ({0 {2 @C {2 @B (a b)}} a} b)
@Option.or = ({3 {2 @C {2 @B (a b)}} a} b)
@Some = (a {2 {4 a b} {2 * b}})
@main = a
& @Option.or ~ (b (@None a))

View File

@ -2,5 +2,5 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/spacing.hvm
---
@main = ({0 (a b) a} b)
@main = ({3 (a b) a} b)

View File

@ -3,4 +3,4 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_term/church_one.hvm
---
a
& ((b (c d)) ({0 (d e) b} (c e))) ~ ((* (f f)) a)
& ((b (c d)) ({3 (d e) b} (c e))) ~ ((* (f f)) a)

View File

@ -2,5 +2,5 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_term/complicated_dup.hvm
---
({0 (a b) (c d)} e)
& ((f {0 a c}) b) ~ ((f d) e)
({5 (a b) (c d)} e)
& ((f {3 a c}) b) ~ ((f d) e)

View File

@ -2,4 +2,4 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_term/dup_apply.hvm
---
({0 (a b) a} b)
({3 (a b) a} b)

View File

@ -3,4 +3,4 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_term/dup_global_lam.hvm
---
a
& ({0 (b c) b} (d d)) ~ (c a)
& ({3 (b c) b} (d d)) ~ (c a)

View File

@ -2,4 +2,4 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_term/erased_dup.hvm
---
({0 * a} a)
({3 * a} a)

View File

@ -2,4 +2,4 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_term/infer_dup.hvm
---
({0 (a b) a} b)
({3 (a b) a} b)

View File

@ -2,4 +2,4 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_term/let_substitution.hvm
---
({0 (a b) a} b)
({3 (a b) a} b)

View File

@ -4,6 +4,6 @@ input_file: tests/golden_tests/compile_term/lets.hvm
---
a
& (b b) ~ (c (d (e a)))
& (f f) ~ {0 (g (h (i e))) {0 g {0 h i}}}
& (j j) ~ {0 (k (l d)) {0 k l}}
& (m m) ~ {0 (n c) n}
& (f f) ~ {9 (g (h (i e))) {11 g {13 h i}}}
& (j j) ~ {5 (k (l d)) {7 k l}}
& (m m) ~ {3 (n c) n}

View File

@ -2,4 +2,4 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/desugar_file/dup_linearization.hvm
---
(main) = let #0{a_1 a_1_dup} = *; let #0{a_2 a_2_dup} = a_1_dup; let #0{a_3 a_3_dup} = a_2_dup; let #0{a_4 a_5} = a_3_dup; ((a_5, a_1), (a_2, (a_3, a_4)))
(main) = let {a_1 a_1_dup} = *; let {a_2 a_2_dup} = a_1_dup; let {a_3 a_3_dup} = a_2_dup; let {a_4 a_5} = a_3_dup; ((a_5, a_1), (a_2, (a_3, a_4)))

View File

@ -2,4 +2,4 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_file/superposed_is_even.hvm
---
#0{#0{T F} #0{T F}}
#0{#1{T F} #2{T F}}

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/addition.hvm
---
10

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/adt_match.hvm
---
(Some 2)

View File

@ -0,0 +1,8 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/adt_match_wrong_tag.hvm
---
Readback Warning:
Unexpected tag found during Adt readback, expected '#Option.Some.val', but found '#wrong_tag'
λa match a { (Some c): #Option.Some.val (#wrong_tag λb b c); (None): * }

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/adt_option_and.hvm
---
λa match a { (Some b): λc (match c { (Some d): λe (Some (e, d)); (None): λ* None } b); (None): λ* None }

View File

@ -0,0 +1,8 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/adt_wrong_tag.hvm
---
Readback Warning:
Unexpected tag found during Adt readback, expected '#Option.Some.val', but found '#wrong_tag'
λa match a { (Some c): #Option.Some.val (#wrong_tag λb b c); (None): * }

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/and.hvm
---
false

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/bitonic_sort.hvm
---
120

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/bitonic_sort_lam.hvm
---
32640

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/box.hvm
---
(Box 10)

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/box2.hvm
---
(Box 4)

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/callcc.hvm
---
52

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/chars.hvm
---
"ሴ!7"

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/def_tups.hvm
---
15

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/dup_global_lam.hvm
---
λa a

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/eta.hvm
---
λa a

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/example.hvm
---
8

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/exp.hvm
---
λa λb (a (a (a (a b))))

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/extracted_match_pred.hvm
---
0

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/field_vectorization.hvm
---
(Cons T (Cons T (Cons F (Cons T Nil))))

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/lam_op2.hvm
---
λa (+ a 2)

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/lam_op2_nested.hvm
---
*

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/let_tup_readback.hvm
---
λa let (b, c) = a; (b c)

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/linearize_match.hvm
---
λa match a { 0: λb b; +a-1: λd (+ a-1 d) }

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/list_resugar.hvm
---
[42, [λd d]]

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/list_reverse.hvm
---
(cons 1 (cons 2 (cons 3 nil)))

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/list_take.hvm
---
[3, 2]

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_lazy/list_to_tree.hvm
---
((1, 2), (3, (4, 5)))

Some files were not shown because too many files have changed in this diff Show More