Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating to Clojure 1.2.0 and <$> #2

Merged
merged 4 commits into from Jun 3, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions project.clj
@@ -1,6 +1,5 @@
(defproject clarsec "0.0.1-SNAPSHOT" (defproject clarsec "0.0.1-SNAPSHOT"
:description "Parsec ported to clojure" :description "Parsec ported to clojure"
:dependencies [[org.clojure/clojure "1.1.0"] :dependencies [[org.clojure/clojure "1.2.1"]
[org.clojure/clojure-contrib "1.0-SNAPSHOT"]] [org.clojure/clojure-contrib "1.2.0"]]
:dev-dependencies [[lein-clojars "0.5.0-SNAPSHOT"]] :dev-dependencies [[lein-clojars "0.5.0-SNAPSHOT"]])
:main eu.dnetlib.dlms.parser)
7 changes: 5 additions & 2 deletions src/eu/dnetlib/clojure/clarsec.clj
Expand Up @@ -59,6 +59,9 @@
;; Bind with a non monadic function ;; Bind with a non monadic function
(defn >>== [p f] (defn >>== [p f]
(bind p #(result (f %)))) (bind p #(result (f %))))
(defn <$> [f p]
(bind p #(result (f %))))



(def any-token (def any-token
(make-monad 'Parser (make-monad 'Parser
Expand Down Expand Up @@ -101,7 +104,7 @@
(def many1) (def many1)


(defn many [parser] (defn many [parser]
(>>== (optional (many1 parser)) (>>== (optional (delay (many1 parser)))
#(if (nil? %) () %))) #(if (nil? %) () %)))


(defn many1 [parser] (defn many1 [parser]
Expand Down Expand Up @@ -195,4 +198,4 @@
((monad (force parser)) input)) ((monad (force parser)) input))


;;(defn -main [] ;;(defn -main []
;; (println (parse (>> (delay letter) (delay letter)) "ca."))) ;; (println (parse (>> (delay letter) (delay letter)) "ca.")))