Serve index.html at / by default in Compojure

An alternative could be to create either a redirect or a direct response in an additional route. Like so: (ns compj-test.core (:use [compojure.core]) (:require [compojure.route :as route] [ring.util.response :as resp])) (defroutes main-routes (GET “https://stackoverflow.com/” [] (resp/file-response “index.html” {:root “public”})) (GET “/a” [] (resp/resource-response “index.html” {:root “public”})) (route/resources “https://stackoverflow.com/”) (route/not-found “Page not found”)) The “https://stackoverflow.com/” route … Read more

How does clojure’s syntax-quote work?

I don’t think there’s a syntax-quote equivalent of the quote function. The Clojure reader is (currently) written in Java. The SyntaxQuoteReader class in src/jvm/clojure/lang/LispReader.java in the Clojure source is probably what you’ll want to read. It seems rather complex. You can see it building lists like (seq (concat …)) there. ret = RT.list(SEQ, RT.cons(CONCAT, sqExpandList(seq))); … Read more

In clojure, how to apply a macro to a list?

You don’t. Macros are expanded during evaluation/compile time, not at runtime, thus the only information they can use are the args passed in, but not what the args evaluate to at runtime. That’s why a literal vector works, because that literal vector is there at compile time, but a is just a symbol; it will … Read more

What is reify in Clojure?

reify is to defrecord what fn is to defn. “Ah right…… so what’s reify” Put simply, protocols are lists of functions a datatype should support, records are datatypes and reifications are anonymous datatypes. Maybe this is long-winded, but reify can’t be understood concretely without understanding protocols and types/records: Protocols are a way to use the … Read more