mirror of
https://github.com/correl/calrissian.git
synced 2024-11-23 19:19:57 +00:00
14 lines
248 B
Text
14 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)
|