calrissian/src/maybe-monad.lfe

15 lines
248 B
Text
Raw Normal View History

2014-04-24 19:33:28 +00:00
(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)