mirror of
https://github.com/correl/calrissian.git
synced 2024-11-27 11:09:58 +00:00
15 lines
248 B
Text
15 lines
248 B
Text
|
(defmodule maybe-monad
|
||
|
(behaviour monad)
|
||
|
(export (>>= 2)
|
||
|
(return 1)
|
||
|
(fail 1)))
|
||
|
|
||
|
(defun >>=
|
||
|
(('nothing f)
|
||
|
'nothing)
|
||
|
(((tuple 'just x) f)
|
||
|
(funcall f x)))
|
||
|
|
||
|
(defun return (x) (tuple 'just x))
|
||
|
(defun fail (_) 'nothing)
|