something something tuples
[minfp.git] / tests / preamble.mfp
index 70fc870..176004a 100644 (file)
@@ -2,12 +2,16 @@
 $ ifxr 0 x y = x y;
 //Reverse function application
 & ifxr 0 x y = y x;
+//Composition
+.. ifxr 9 f g x = f (g x);
 
 //Arithmetic operators
 == ifxl 7 = code eq;
 * ifxl 7 = code mul;
 - ifxl 6 = code sub;
 + ifxl 6 = code add;
+fst = code fst;
+snd = code snd;
 
 on f g a b = f (g a) (g b);
 
@@ -19,3 +23,10 @@ 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);
+
+return a = \s. (a, s);
+>>= ifxr 0 ma atmb = \s. uncurry atmb (ma s);
+
+start = fst ((return 41 >>= \x. return (x + 1)) 4);