Hi, I'm trying to learn how to make DSL in Clojure and Korma project is a really good place to learn from. I'm trying this very simple stuff (inspired by Korma, not Korma code):
(def predicates {'and :and 'or :or 'not :not '> :gt '< :lt '= :eq}) (defn parse-where [form] (walk/postwalk-replace predicates form)) (defn condition->map [clause] (apply hash-map (conj clause :op))) (defn clauses->vec [clauses] (reduce #(conj %1 (condition->map %2)) [ ] (rest clauses))) (defn select* [ ] {:type :select}) (defmacro select [& body] (make-query-then-execute #'select* body)) (defn- make-query-then-execute [fn-var body] `(let [query-map# (-> (~fn-var) ~@body)] query-map#)) (defn where-form [where-form* query form] `(let [q# ~query] (~where-form* q# (clauses->vec ~(parse-where `~form))))) (defmacro where [query form] (where-form #'where* query form)) (defn where* [query clause] (update-in query [:where] conj clause)) But when I'm trying in the REPL: (select (where (and (= :version 1.6) (= :name "Clojure")) I'm getting: ClassCastException java.lang.Character cannot be cast to clojure.lang.IPersistentCollection clojure.core/conj (core.clj:83) It is really hard to me to know what is going wrong. What is confusing me, if I'm trying the where macro alone, it is working as excepted but when integrating it with select macro, I got the exception. I know it is not your problem but your help is greatly appreciated. Thanks for help and time. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.