Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Updating to Clojure 1.2.0 and <$> #2

Merged
merged 4 commits into from

2 participants

@devn

Thanks in advance.

@mmikulicic mmikulicic merged commit 778080a into mmikulicic:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 2, 2011
  1. fixed param ordering on <$>

    Jason Jackson authored
  2. fixed bug where calling many with a recursive parser would cause stac…

    Jason Jackson authored
    …koverflow.
Commits on Jun 3, 2011
  1. @devn

    Merge pull request #1 from jasonjckn/master

    devn authored
    <$> From Haskell
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 6 deletions.
  1. +3 −4 project.clj
  2. +5 −2 src/eu/dnetlib/clojure/clarsec.clj
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.")))
Something went wrong with that request. Please try again.