1
1
mirror of https://github.com/anoma/juvix.git synced 2024-11-30 14:13:27 +03:00
juvix/tests/Core/positive/test007.jvc
Łukasz Czajka 98b1daec7d
Print JuvixCore correctly (#1875)
Print JuvixCore InfoTable in such a way that it can be parsed back by
the JuvixCore parser.

* Depends on PR #1832 
* Depends on PR #1862 
* Closes #1841 
* Adds "JuvixCore print" tests which read the files from
Core/positive/*.jvc, print them, read them back and check if the
evaluation results are preserved.

---------

Co-authored-by: Jan Mas Rovira <janmasrovira@gmail.com>
2023-03-15 16:41:39 +01:00

26 lines
601 B
Plaintext

-- case
type list {
nil : list;
cons : Any -> list -> list;
};
def hd := \x case x of { cons x' _ := x' };
def tl := \x case x of { cons _ x' := x' };
def null := \x case x of { nil := true; _ := false };
def map := \f \x case x of { nil := nil; cons h t := cons (f h) (map f t) };
def map' := \f \x if null x then nil else cons (f (hd x)) (map' f (tl x));
def lst := cons 0 (cons 1 nil);
def writeLn := \x write x >> write "\n";
writeLn (null lst) >>
writeLn (null nil) >>
writeLn (hd lst) >>
writeLn (tl lst) >>
writeLn (hd (tl lst)) >>
writeLn (map (+ 1) lst) >>
writeLn (map' (+ 1) lst)