clojure

Merveille van Eck 2026-01-03T11:00:36.269519Z

im no beginner but this completely stumped me:

(defn metadata [func]
  (-> (class func)
      (print-str)
      (demunge)
      (symbol)
      (find-var)
      (meta)))

(defn- extract-openapi-meta [handler]
  (-> (metadata handler)
      (dissoc :arglists :line :column :file :name :ns)))

(defn- attach-handler [handler openapi-meta]
  (assoc openapi-meta :handler handler))

(->> (extract-openapi-meta units/get-all)
     (partial attach-handler (fn [] (prn "prn")))) ;; => #function[clojure.core/partial] ????

Merveille van Eck 2026-01-03T11:02:30.499859Z

units/get-all looks like this:

(defn get-all
  {:summary "get all units"
   :responses (api/success api/GetUnitsResponse)}
  [{:keys [ds] :as _request}]
  (res/response (units/get-all-units ds)))

Merveille van Eck 2026-01-03T11:03:32.589889Z

trying to extract the metadata of the request, the bottom most thread imo should return a map, not a function. am i not understanding partial?

exitsandman 2026-01-03T11:04:49.084129Z

(->> A (partial B C)) expands to (partial A B C) which of course evaluates to a function

Merveille van Eck 2026-01-03T11:05:14.061529Z

hmmm, so i must have misunderstood then

Merveille van Eck 2026-01-03T11:06:05.795949Z

i guess because ->> is a thread macro it operates on partial and not on the result of partial

Merveille van Eck 2026-01-03T11:07:43.257659Z

i will just use merge instead, seems more appropriate here. thanks sandman!

Mario G 2026-01-03T12:04:29.539629Z

> expands to (partial A B C) with thread-last (used here) would be (partial B C A)😉 > thread macro it operates on partial and not on the result of partial Unsure what would be the intended result of partial if the output of the partial application is not invoked with any additional args (or none of them). I have the impression you'd expect partial to work here like apply would so I wonder if this - apply - would fit your bill 🙂 I'm also a bit lost on using merge rather than partial, maybe merge does what you expect but merge and partial are two very different beasts.

Merveille van Eck 2026-01-03T12:18:09.232759Z

what i should have done was simply

(->> (edxtract-openapi-meta handler)
      (attach-handler handler))

Merveille van Eck 2026-01-03T12:18:57.623119Z

merge here would remove the need for attach-handler altogether and instead turn it into

(->> (extrac-openapi-meta handler_)
     (merge {:handler handler}))

Merveille van Eck 2026-01-03T12:19:04.332919Z

so no need for an additional function

Mario G 2026-01-03T12:30:43.554229Z

I guess that even ->> could go, I mean, from (->> A (merge B)) to (merge B A)

teodorlu 2026-01-03T14:04:57.127369Z

I generally don't need partial at all when working inside -> or ->>:

(->> 10
     (partial * 7))
;; => #function[clojure.core/partial/fn--5929]

(->> 10
     (* 7))
;; => 70
But if you really want partial, you can add extra parentheses. Then ->> will stitch the argument in the right place.
(->> 10
     ((partial * 7) #_"->> puts 10 here"))
;; => 70

1
teodorlu 2026-01-03T14:07:09.435369Z

I don't undertstand precisely where you're going with your code, but -> works very nicely with maps and map functions like assoc.

(-> {:your "map"}
    (assoc :handler #(prn "prn")))
;; => {:your "map", :handler #function[terra.assetwatch/eval11699/fn--11700]}

2026-01-03T17:37:14.819459Z

Does anyone know whether docjure supports streaming from an Excel file (or what else to do if it doesn't)? I need to read a really big one into an sqlite database and it kills the jvm

dorab 2026-01-03T18:27:12.128299Z

It's not docjure, but if you want to just read an Excel file and put it in a db, then perhaps Java interop with https://github.com/monitorjbl/excel-streaming-reader might work for you.

2026-01-03T19:20:25.243169Z

Thanks!

respatialized 2026-01-04T02:06:56.785599Z

tbh, I would just use https://duckdb.org/ for what you're describing rather than do it in Clojure

2026-01-05T08:20:52.914499Z

I was thinking about that too, but if I understand it correctly, this would make it a bit inconvenient to store each row in a json - which is what I am trying to do. I am basically using sqlite as a local document database, which iirc is not what DuckDB is optimized for

Jonas Rodrigues 2026-01-05T10:09:13.367709Z

Not answering the original post, just adding to the DuckDB suggestion: you could use the Excel extension (https://duckdb.org/docs/stable/core_extensions/excel) to read Excel data and save it to SQLite. We do this at work, use DuckDB as a generic way to read data from multiple sources and save it to SQLite databases.

respatialized 2026-01-07T14:21:36.286719Z

https://duckdb.org/docs/stable/data/json/json_type - DuckDB has a JSON logical type too, I would be surprised if it failed to handle Excel-sized data