aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/monads.clj
diff options
context:
space:
mode:
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