From babe62b2320dc7a937ef30437b59c7b7e73f3c37 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sat, 24 Sep 2016 15:01:04 +0200 Subject: Added examples --- examples/monad.fusp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 examples/monad.fusp (limited to 'examples/monad.fusp') 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); -- cgit v1.2.3