rlm@2: rlm@2: (ns categorical.monad) rlm@2: (use 'clojure.contrib.monads) rlm@2: rlm@2: (in-ns 'categorical.monad) rlm@2: rlm@2: ;; To implement nondeterministic programs, we'll use a lazy seq to represent a value which may be any one of the members of seq. rlm@2: rlm@2: (defmonad amb rlm@2: [ rlm@2: m-result (fn[& vals] (cons 'amb vals)) rlm@2: m-bind (fn[amb-seq f] (cons 'amb (map f (rest amb-seq)))) rlm@2: ] rlm@2: )