Commits

Meikel Brandmeyer committed 8e2cdd0

Changed tag systems from keywords to Symbols

Comments (0)

Files changed (4)

src/de/kotka/monad.clj

   (:use
      [clojure.contrib.def :only (defstruct-)]))
 
-(derive ::mzero ::monad)
+(declare Monad MZero)
+
+(derive `MZero `Monad)
 
 (defstruct- monad-structure :type :monad)
 
   return
   (fn [t _] t))
 
-(defmethod return ::monad
+(defmethod return `Monad
   [t m]
   (make-monad t m))
 
   Although this cannot be enforced in Clojure."}
   bind (fn [m _] (monad-type m)))
 
-(defmethod bind ::mzero [m _] m)
-(defmethod bind ::monad [m f] (f (monad m)))
+(defmethod bind `MZero [m _] m)
+(defmethod bind `Monad [m f] (f (monad m)))
 
 (defmulti
   #^{:doc
-  "If the first argument is not a ::mzero, return it. Otherwise return
+  "If the first argument is not a `MZero, return it. Otherwise return
   the second value."}
   mplus
   (fn [m1 m2] #(vec (map monad-type [%1 %2]))))
 
-(defmethod mplus [::mzero ::monad] [_ m2] m2)
-(defmethod mplus [::monad ::monad] [m1 _] m1)
+(defmethod mplus [`MZero `Monad] [_ m2] m2)
+(defmethod mplus [`Monad `Monad] [m1 _] m1)
 
 (defmacro let-bind
   "let-bind binds the result of the given monads to the given variables

src/de/kotka/monad/error.clj

      de.kotka.monad.maybe
      [clojure.contrib.def :only (defvar)]))
 
-(derive ::success :de.kotka.monad/monad)
-(derive ::failure :de.kotka.monad/mzero)
+(declare Success Failure)
+
+(derive `Success `Monad)
+(derive `Failure `MZero)
 
 (defmulti
   #^{:arglists '[(result-or-error handler)]
   catch-error
   (fn [m _] (monad-type m)))
 
-(defmethod catch-error ::success [m _] m)
-(defmethod catch-error ::failure [m h] (h (monad m)))
+(defmethod catch-error `Success [m _] m)
+(defmethod catch-error `Failure [m h] (h (monad m)))

src/de/kotka/monad/maybe.clj

      de.kotka.monad
      [clojure.contrib.def :only (defvar)]))
 
-(derive ::nothing :de.kotka.monad/mzero)
-(derive ::just    :de.kotka.monad/monad)
+(declare Nothing Just)
+
+(derive `Nothing `MZero)
+(derive `Just    `Monad)
 
 (defvar
   nothing
-  (make-monad ::nothing `nothing)
+  (make-monad `Nothing nil)
   "nothing represents the empty value of the maybe monad.")
 
 (defn is-nothing?
   "Predicate for testing, whether a given monad represents nothing."
   [m]
-  (= (monad-type m) ::nothing))
+  (= (monad-type m) `Nothing))
 
 (defn is-just?
   "Predicate for testing, whether a given monad represents some value."
   [m]
-  (= (monad-type m) ::just))
+  (= (monad-type m) `Just))
 
 (defmulti
   #^{:arglists '[(monad) (monad default)]
   from-maybe
   #(monad-type %))
 
-(defmethod from-maybe ::just
+(defmethod from-maybe `Just
   [m & _]
   (monad m))
 
-(defmethod from-maybe ::nothing
+(defmethod from-maybe `Nothing
   ([_]
    (throw (Exception. "Tried to retrieve a value from nothing")))
   ([_ default]

src/de/kotka/monad/state.clj

      de.kotka.monad
      [clojure.contrib.def :only (defvar)]))
 
-(derive ::state :de.kotka.monad/monad)
+(declare State)
 
-(defmethod return ::state
+(derive `State `Monad)
+
+(defmethod return `State
   "Sets the value but leaves the state intact."
   [x]
-  (make-monad ::state #(vector x %)))
+  (make-monad `State #(vector x %)))
 
 (defvar
   get-state
-  (make-monad ::state #(vector % %))
+  (make-monad `State #(vector % %))
   "Returns the state as the value.")
 
 (defn put-state
   "Sets the state and a nil value."
   [s]
-  (make-monad ::state (fn [_] [nil s])))
+  (make-monad `State (fn [_] [nil s])))
 
 (defn run-state
   "Apply a state monad to the given initial state. Returns a vector
   "Run the given state monad and return its final state. Equivalent to
   run-state followed by second.")
 
-(defmethod bind ::state
+(defmethod bind `State
   [m f]
-  (make-monad ::state
+  (make-monad `State
               (fn [s0]
                 (let [[a s1] (run-state m s0)]
                   (run-state (f a) s1)))))