Skip to content

Instantly share code, notes, and snippets.

View js-choi's full-sized avatar
💭
I may be slow to respond.

J. S. Choi js-choi

💭
I may be slow to respond.
View GitHub Profile
(let*
[maker-var__35822__auto__
(clojure.core/defn
edu.arizona.fnparse.hound/validate
"Creates a validating rule.\n \n A convenience function. Returns a new rule that\n acts like the given `rule`, but also validates\n `rule`'s products with the given predicate.\n Basically just a shortcut for `for` and `when`."
{:no-memoize? true,
:success
"When `rule` succeeds and its product fulfills `(pred product)`.",
:product "`rule`'s product.",
:consumes "What `rule` consumes."}
(defn named-rule-maker [rule-making-fn rule-type-kw]
(fn named-rule-maker [& args]
(NamedRule. (delay (apply-seq rule-making-fn args)) rule-type-kw)))
(defmacro general-defmaker [def-form description rule-type-kw fn-name & forms]
`(let [maker-var# (~def-form ~fn-name ~@forms)]
(alter-var-root maker-var# named-rule-maker ~rule-type-kw) ; Commenting this out prevents the error.
maker-var#))
ser=> (require '[edu.arizona.fnparse [core :as c] [hound :as h]] :reload)
java.lang.RuntimeException: Can't embed object in code, maybe print-dup not defined: clojure.lang.Delay@65f0518c (hound.clj:445)
(let*
[maker-var__35822__auto__
(clojure.core/defn
edu.arizona.fnparse.hound/validate
"Creates a validating rule.\n \n A convenience function. Returns a new rule that\n acts like the given `rule`, but also validates\n `rule`'s products with the given predicate.\n Basically just a shortcut for `for` and `when`."
{:no-memoize? true,
:success
"When `rule` succeeds and its product fulfills `(pred product)`.",
clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Can't embed object in code, maybe print-dup not defined: clojure.lang.Delay@41dee0d7 (hound.clj:427)
at clojure.lang.Compiler.analyzeSeq (Compiler.java:5376)
clojure.lang.Compiler.analyze (Compiler.java:5190)
clojure.lang.Compiler.analyzeSeq (Compiler.java:5357)
clojure.lang.Compiler.analyze (Compiler.java:5190)
clojure.lang.Compiler.analyze (Compiler.java:5151)
clojure.lang.Compiler$HostExpr$Parser.parse (Compiler.java:798)
clojure.lang.Compiler.analyzeSeq (Compiler.java:5369)
clojure.lang.Compiler.analyze (Compiler.java:5190)
bash> lein self-install
Downloading Leiningen now...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 8076k 100 8076k 0 0 1716k 0 0:00:04 0:00:04 --:--:-- 2535k
bash> lein help
WARNING: reader macro ^ is deprecated; use meta instead
Exception in thread "main" java.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Named (help.clj:5)
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:2780)