aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/monads.clj
diff options
context:
space:
mode:
authorKonrad Hinsen <konrad.hinsen@laposte.net>2009-02-14 18:24:28 +0000
committerKonrad Hinsen <konrad.hinsen@laposte.net>2009-02-14 18:24:28 +0000
commitc108accfbd38e4fabbf369e913e2ccd748d40d50 (patch)
tree2affab4665db2f161f6993f30c0711d43618e3b7 /src/clojure/contrib/monads.clj
parent12a6c47ae73e749f65895ccc2af2faee82a8eb01 (diff)
monads: added identity monad
Diffstat (limited to 'src/clojure/contrib/monads.clj')
-rw-r--r--src/clojure/contrib/monads.clj12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/clojure/contrib/monads.clj b/src/clojure/contrib/monads.clj
index 72e6199d..7fcac162 100644
--- a/src/clojure/contrib/monads.clj
+++ b/src/clojure/contrib/monads.clj
@@ -1,7 +1,7 @@
;; Monads in Clojure
;; by Konrad Hinsen
-;; last updated February 10, 2009
+;; last updated February 14, 2009
;; Copyright (c) Konrad Hinsen, 2009. All rights reserved. The use
;; and distribution terms for this software are covered by the Eclipse
@@ -208,6 +208,16 @@
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; Identity monad
+(defmonad id
+ "Monad describing plain computations. This monad does in fact nothing
+ at all. It is useful for testing, for combination with monad
+ transformers, and for code that is parameterized with a monad."
+ [m-result identity
+ m-bind (fn m-result-id [mv f]
+ (f mv))
+ ])
+
; Maybe monad
(defmonad maybe
"Monad describing computations with possible failures. Failure is