Updating to Clojure 1.2.0 and <$> #2

Merged
merged 4 commits into from Jun 3, 2011
View
7 project.clj
@@ -1,6 +1,5 @@
(defproject clarsec "0.0.1-SNAPSHOT"
:description "Parsec ported to clojure"
- :dependencies [[org.clojure/clojure "1.1.0"]
- [org.clojure/clojure-contrib "1.0-SNAPSHOT"]]
- :dev-dependencies [[lein-clojars "0.5.0-SNAPSHOT"]]
- :main eu.dnetlib.dlms.parser)
+ :dependencies [[org.clojure/clojure "1.2.1"]
+ [org.clojure/clojure-contrib "1.2.0"]]
+ :dev-dependencies [[lein-clojars "0.5.0-SNAPSHOT"]])
View
7 src/eu/dnetlib/clojure/clarsec.clj
@@ -59,6 +59,9 @@
;; Bind with a non monadic function
(defn >>== [p f]
(bind p #(result (f %))))
+(defn <$> [f p]
+ (bind p #(result (f %))))
+
(def any-token
(make-monad 'Parser
@@ -101,7 +104,7 @@
(def many1)
(defn many [parser]
- (>>== (optional (many1 parser))
+ (>>== (optional (delay (many1 parser)))
#(if (nil? %) () %)))
(defn many1 [parser]
@@ -195,4 +198,4 @@
((monad (force parser)) input))
;;(defn -main []
-;; (println (parse (>> (delay letter) (delay letter)) "ca.")))
+;; (println (parse (>> (delay letter) (delay letter)) "ca.")))