Meikel  Brandmeyer avatar Meikel Brandmeyer committed 2a42029

Move monad.clj up one directory for AOT

Comments (0)

Files changed (2)

de/kotka/monad/monad.clj

-;-
-; Copyright 2008 (c) Meikel Brandmeyer.
-; All rights reserved.
-;
-; Permission is hereby granted, free of charge, to any person obtaining a copy
-; of this software and associated documentation files (the "Software"), to deal
-; in the Software without restriction, including without limitation the rights
-; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-; copies of the Software, and to permit persons to whom the Software is
-; furnished to do so, subject to the following conditions:
-;
-; The above copyright notice and this permission notice shall be included in
-; all copies or substantial portions of the Software.
-;
-; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-; THE SOFTWARE.
-
-(comment
-  "Description
-  -----------
-
-  `monad` is a small support library for Clojure_ which provides some of
-  the infrastructure to handle monads. A monad is defined as a `struct-map`
-  which contains the key `:monad`, which defines the type of the actual
-  monad. This value is used as the dispatch value for the `bind` multimethod.
-  `bind` is obviously dependent on the actual monad implementation.
-
-  On application of monads are for example the parser combinators. Here
-  the monads server as means to combine different parsers together to form
-  new parsers. An example implementation for Clojure_ is „Parser_“ from the
-  same author.
-
-  .. _Clojure: http://clojure.org
-  .. _Parser:  http://kotka.de/projects/clojure/parser.html")
-
-(clojure/in-ns 'de.kotka.monad)
-(clojure/refer 'clojure)
-
-(def
-  #^{:doc
-  "Description
-  -----------
-
-  `monad-structure` defines the basic structure of the monad supporting
-  structure. The :monad key is the dispatch value for the `bind` multimethod.
-  Whatever else is contained in the structure is completely up to the actual
-  implementation and will not be touched by the functions of the monad library."}
-  monad-structure
-  (create-struct :monad))
-
-(defn make-monad
-  "Synopsis
-  --------
-
-  (make-monad monad-type key value ...)
-
-  Description
-  -----------
-
-  `make-monad` creates a new monad structure and associates the :monad key
-  with given monad-type. What the monad-type actually is, is up to the caller.
-  This value will be used for dispatching in the `bind` multimethod.
-
-  Any further key-value pairs will be associated with the map."
-  [monad-type & kvs]
-  (apply struct-map monad-structure :monad monad-type kvs))
-
-(defmulti
-  #^{:doc
-  "Synopsis
-  --------
-
-  (bind monad (fn [result] ...)) : Monad a -> (a -> b)-> Monad b
-
-  Description
-  -----------
-
-  `bind` makes the value of the given monad available to a function.
-  The function may act on the value, but it must return another monad.
-  (Although this cannot be enforced in Clojure."}
-  bind (fn [m f] (:monad m)))
-
-(defmacro let-bind
-  "Synopsis
-  --------
-
-  (let [var1 monad1
-        ...
-        varN monadN]
-    body ...)
-
-  Description
-  -----------
-
-  `let-bind` binds the result of the given monads to the given variables
-  and executes the body in an implicit `do` block. How this done exactly
-  depends on the actual monad. The `let-bind` body should again return a
-  monad."
-  [clauses & body]
-  (let [[var monad & clauses] clauses]
-    (if (nil? clauses)
-      `(bind ~monad (fn [~var] ~@body))
-      `(bind ~monad (fn [~var] (let-bind ~clauses ~@body))))))

src/de/kotka/monad.clj

+;-
+; Copyright 2008 (c) Meikel Brandmeyer.
+; All rights reserved.
+;
+; Permission is hereby granted, free of charge, to any person obtaining a copy
+; of this software and associated documentation files (the "Software"), to deal
+; in the Software without restriction, including without limitation the rights
+; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+; copies of the Software, and to permit persons to whom the Software is
+; furnished to do so, subject to the following conditions:
+;
+; The above copyright notice and this permission notice shall be included in
+; all copies or substantial portions of the Software.
+;
+; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+; THE SOFTWARE.
+
+(comment
+  "Description
+  -----------
+
+  `monad` is a small support library for Clojure_ which provides some of
+  the infrastructure to handle monads. A monad is defined as a `struct-map`
+  which contains the key `:monad`, which defines the type of the actual
+  monad. This value is used as the dispatch value for the `bind` multimethod.
+  `bind` is obviously dependent on the actual monad implementation.
+
+  On application of monads are for example the parser combinators. Here
+  the monads server as means to combine different parsers together to form
+  new parsers. An example implementation for Clojure_ is „Parser_“ from the
+  same author.
+
+  .. _Clojure: http://clojure.org
+  .. _Parser:  http://kotka.de/projects/clojure/parser.html")
+
+(clojure.core/ns de.kotka.monad)
+
+(def
+  #^{:doc
+  "Description
+  -----------
+
+  `monad-structure` defines the basic structure of the monad supporting
+  structure. The :monad key is the dispatch value for the `bind` multimethod.
+  Whatever else is contained in the structure is completely up to the actual
+  implementation and will not be touched by the functions of the monad library."}
+  monad-structure
+  (create-struct :monad))
+
+(defn make-monad
+  "Synopsis
+  --------
+
+  (make-monad monad-type key value ...)
+
+  Description
+  -----------
+
+  `make-monad` creates a new monad structure and associates the :monad key
+  with given monad-type. What the monad-type actually is, is up to the caller.
+  This value will be used for dispatching in the `bind` multimethod.
+
+  Any further key-value pairs will be associated with the map."
+  [monad-type & kvs]
+  (apply struct-map monad-structure :monad monad-type kvs))
+
+(defmulti
+  #^{:doc
+  "Synopsis
+  --------
+
+  (bind monad (fn [result] ...)) : Monad a -> (a -> b)-> Monad b
+
+  Description
+  -----------
+
+  `bind` makes the value of the given monad available to a function.
+  The function may act on the value, but it must return another monad.
+  (Although this cannot be enforced in Clojure."}
+  bind (fn [m f] (:monad m)))
+
+(defmacro let-bind
+  "Synopsis
+  --------
+
+  (let [var1 monad1
+        ...
+        varN monadN]
+    body ...)
+
+  Description
+  -----------
+
+  `let-bind` binds the result of the given monads to the given variables
+  and executes the body in an implicit `do` block. How this done exactly
+  depends on the actual monad. The `let-bind` body should again return a
+  monad."
+  [clauses & body]
+  (let [[var monad & clauses] clauses]
+    (if (nil? clauses)
+      `(bind ~monad (fn [~var] ~@body))
+      `(bind ~monad (fn [~var] (let-bind ~clauses ~@body))))))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.