From 7bc67b95161a34f8eca635d4000d9602508a9243 Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Mon, 23 Dec 2019 01:32:39 +0000 Subject: checkpoint --- examples/maybe.sin | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 examples/maybe.sin (limited to 'examples/maybe.sin') diff --git a/examples/maybe.sin b/examples/maybe.sin new file mode 100644 index 0000000..91367cd --- /dev/null +++ b/examples/maybe.sin @@ -0,0 +1,22 @@ +[type just_ [kind val]] +[type none_ [kind]] + +[def just [val] + [just_ 1 val]] + +[def just.val [x] + [just_.val x]] + +[def none [] + [none_ 0]] + +[def has_value [x] + [just_.kind x]] + +[def Maybe.>>= [a f] + [if [has_value a] + [f [just.val a]] + a]] + +[def Maybe.return [x] + [just x]] -- cgit v1.2.1