aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/monads/examples.clj
diff options
context:
space:
mode:
authorKonrad Hinsen <konrad.hinsen@laposte.net>2009-01-08 09:30:54 +0000
committerKonrad Hinsen <konrad.hinsen@laposte.net>2009-01-08 09:30:54 +0000
commit081456e0ac0880450993f7d50d56609b16b1cfb6 (patch)
tree6db7213d351247fbf543c5a08dc410131c1e5546 /src/clojure/contrib/monads/examples.clj
parent806accca611331f50e30f2ff65bbf75695977cee (diff)
monads.clj: modified maybe monad, added monad transformer maybe-t, changed default value of all monad operations from nil to ::undefined
Diffstat (limited to 'src/clojure/contrib/monads/examples.clj')
-rw-r--r--src/clojure/contrib/monads/examples.clj12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/clojure/contrib/monads/examples.clj b/src/clojure/contrib/monads/examples.clj
index 89515c49..8ddf91be 100644
--- a/src/clojure/contrib/monads/examples.clj
+++ b/src/clojure/contrib/monads/examples.clj
@@ -93,16 +93,8 @@
; Division is special for two reasons: we can't call it m/ because that's
; not a legal Clojure symbol, and we want it to fail if a division by zero
-; is attempted. It can be defined explictly:
-(with-monad maybe
- (defn safe-div [x y]
- (cond (= m-zero x) m-zero
- (= m-zero y) m-zero
- (= (first y) 0) m-zero
- :else (m-result (/ (first x) (first y))))))
-
-; It can also be defined as a monad comprehension that performs the test
-; in a :when clause:
+; is attempted. It is best defined by a monad comprehension with a
+; :when clause:
(defn safe-div [x y]
(domonad maybe
[a x