aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2022-09-26 16:29:32 +0300
committerJan Tuomi <jans.tuomi@gmail.com>2022-12-05 14:21:53 +0200
commitf8578936553468785ff1c70fb7f4b0efebfbf55d (patch)
treea726d8d206cd58591ec05895fce5f513a2c6a764 /examples
parent367cefd18ba6c96c9753e69a19db84ce50f34abf (diff)
Add maybe concept
Diffstat (limited to 'examples')
-rw-r--r--examples/maybe.lisp (renamed from examples/algebraic-types-concept.lisp)9
1 files changed, 9 insertions, 0 deletions
diff --git a/examples/algebraic-types-concept.lisp b/examples/maybe.lisp
index 315a693..ce2cd03 100644
--- a/examples/algebraic-types-concept.lisp
+++ b/examples/maybe.lisp
@@ -1,3 +1,5 @@
+; LIB
+
(let just (\[a]
["maybe" "just" a]))
(let nothing (\[]
@@ -13,6 +15,13 @@
(let from-just (at 2))
(let kind (at 1))
+(let map (\[f m]
+ (match (kind m)
+ "just" (just (f (from-just m)))
+ "nothing")))
+
+; TESTING
+
(let m (just 10))
(match (kind m)
"just" (from-just m)