aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/monads
diff options
context:
space:
mode:
authorKonrad Hinsen <konrad.hinsen@laposte.net>2009-03-02 11:35:07 +0000
committerKonrad Hinsen <konrad.hinsen@laposte.net>2009-03-02 11:35:07 +0000
commitadef4d0980992077b804796f80cceb7b5f9ee780 (patch)
treecdd11986ae3ca4174efd43f869e847cba2d7f2bf /src/clojure/contrib/monads
parente349bec891f980cad20e0fa734045a6bd57820e2 (diff)
General revision of my modules:
- Replaced clojure.contrib.macros/letfn by clojure.core/letfn - Introduced namespaces for all tests and examples - Fixed namespace-related bugs in monads and stream-utils - Introduced :only clause into all :use clauses
Diffstat (limited to 'src/clojure/contrib/monads')
-rw-r--r--src/clojure/contrib/monads/examples.clj10
-rw-r--r--src/clojure/contrib/monads/test.clj13
2 files changed, 15 insertions, 8 deletions
diff --git a/src/clojure/contrib/monads/examples.clj b/src/clojure/contrib/monads/examples.clj
index 96632097..2d3dbb12 100644
--- a/src/clojure/contrib/monads/examples.clj
+++ b/src/clojure/contrib/monads/examples.clj
@@ -7,7 +7,14 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(ns clojure.contrib.monads.examples
- (:use clojure.contrib.monads)
+ (:use [clojure.contrib.monads
+ :only (domonad with-monad m-lift m-seq m-when
+ sequence-m
+ maybe-m
+ state-m fetch-state set-state
+ writer-m write
+ cont-m run-cont call-cc
+ maybe-t)])
(:require (clojure.contrib [accumulators :as accu])))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -43,7 +50,6 @@
(list x y))
; An example of a sequence function defined in terms of a lift operation.
-; We use m-lift2 because we have to lift a function of two arguments.
(with-monad sequence-m
(defn pairs [xs]
((m-lift 2 #(list %1 %2)) xs xs)))
diff --git a/src/clojure/contrib/monads/test.clj b/src/clojure/contrib/monads/test.clj
index 9fbe3928..8053b30a 100644
--- a/src/clojure/contrib/monads/test.clj
+++ b/src/clojure/contrib/monads/test.clj
@@ -1,7 +1,7 @@
;; Test routines for monads.clj
;; by Konrad Hinsen
-;; last updated February 18, 2009
+;; last updated March 2, 2009
;; Copyright (c) Konrad Hinsen, 2008. All rights reserved. The use
;; and distribution terms for this software are covered by the Eclipse
@@ -11,10 +11,11 @@
;; agreeing to be bound by the terms of this license. You must not
;; remove this notice, or any other, from this software.
-(ns clojure.contrib.test-monads
- (:use clojure.contrib.test-is
- clojure.contrib.monads
- clojure.contrib.macros))
+(ns clojure.contrib.monads.test
+ (:use [clojure.contrib.test-is :only (deftest are run-tests)]
+ [clojure.contrib.monads
+ :only (with-monad domonad m-lift m-seq m-chain
+ sequence-m maybe-m maybe-t)]))
(deftest sequence-monad
(with-monad sequence-m
@@ -48,7 +49,7 @@
(deftest seq-maybe-monad
(with-monad (maybe-t sequence-m)
- (letfn-kh [pairs [xs] ((m-lift 2 #(list %1 %2)) xs xs)]
+ (letfn [(pairs [xs] ((m-lift 2 #(list %1 %2)) xs xs))]
(are (= _1 _2)
((m-lift 1 inc) (for [n (range 10)] (when (odd? n) n)))
'(nil 2 nil 4 nil 6 nil 8 nil 10)