Skip to content

Commit 1ba4d72

Browse files
committed
More examples
1 parent 26d253b commit 1ba4d72

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Examples/Typed/more.lam

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
TYPEDEF PII := Int *T Int;
2+
DEFINE sum := lam x :: PII -> proj1 x + proj2 x;
3+
EVAL : sum . < 2, 3 >;
4+
5+
TYPEDEF triple := Int *T Int *T Int;
6+
DEFINE sum3 := lam x :: triple -> proj1 x + (proj1 (proj2 x)) + (proj2 (proj2 x));
7+
EVAL : sum3 . < 3, <4, 5> >;
8+
9+
DEFINE eqInt := lam x, y :: Int -> !(x < y) && !(y < x);
10+
EVAL: eqInt . 1 . 2;
11+
EVAL: eqInt . 2 . 2;
12+
EVAL: eqInt . 3 . 2;
13+
EVAL: eqInt . -10 . (0 - 1 - 9);
14+
15+
TYPEDEF EitherIntFun := Int +T (Int => Int);
16+
DEFINE foo := lam x :: EitherIntFun -> case x of inl i => i | inr f => (f . 42);
17+
EVAL: foo . (inr (lam x :: Int -> x * 2) as EitherIntFun);

0 commit comments

Comments
 (0)