aboutsummaryrefslogtreecommitdiff
path: root/examples/monad.fusp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/monad.fusp')
-rw-r--r--examples/monad.fusp14
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/monad.fusp b/examples/monad.fusp
new file mode 100644
index 0000000..b71e1c1
--- /dev/null
+++ b/examples/monad.fusp
@@ -0,0 +1,14 @@
+left x = (x, 0);
+right x = (0, x);
+
+pure = right;
+bind (l,0) f = (l,0);
+bind (0,r) f = f r;
+
+mul a b = code mul a b;
+sub a b = code sub a b;
+
+mulM x y = right (mul x y);
+subM x y = right (sub x y);
+
+main = bind (bind (pure 5) (mulM 10)) (subM 10);