Add structured types for parsing and type checking
[minfp.git] / tests / preamble.mfp
index 250ceb1..a04ee7a 100644 (file)
@@ -1,9 +1,15 @@
-:: List a = Nil Int;
+:: List a = Nil | Cons a (List a);
+:: Tuple a b = Tuple a b;
+:: Either a b = Left a | Right b;
+:: Maybe a = Nothing | Just a;
+:: St s a = St (s -> Tuple a s);
 
 //Function application
 $ ifxr 0 x y = x y;
 //Reverse function application
 & ifxr 0 x y = y x;
+//Flip
+flip f x y = f y x;
 //Composition
 .. ifxr 9 f g x = f (g x);
 
@@ -12,8 +18,8 @@ $ ifxr 0 x y = x y;
 * ifxl 7 = code mul;
 - ifxl 6 = code sub;
 + ifxl 6 = code add;
-fst = code fst;
-snd = code snd;
+//fst = code fst;
+//snd = code snd;
 
 on f g a b = f (g a) (g b);
 
@@ -26,9 +32,9 @@ id x = x;
 even i = if (i == 0) True (odd (i - 1));
 odd i = if (i == 0) False (even (i - 1));
 
-uncurry f t = f (fst t) (snd t);
+//uncurry f t = f (fst t) (snd t);
 
-return a = \s. (a, s);
->>= ifxr 0 ma atmb = \s. uncurry atmb (ma s);
+return a = St $ Tuple a;
+//>>= ifxr 0 ma atmb = \s. uncurry atmb (ma s);
 
-start = 42; //fst ((return 41 >>= \x. return (x + 1)) 4);
+start = St;