clojure-spec

2024-09-28T18:48:54.986409Z

I have a function with an argument list [a & b]. What is the spec for this? I've tried various things, but the clojure-spec documentation is sparse to the point of unhelpfulness and most of the questions in this channel seem to be dealing with more complex situations than I have. If there's a good tutorial around, that might help me, too.

seancorfield 2024-09-28T18:56:33.378379Z

:args (s/cat :a ... :b (s/* ...)) I think...

seancorfield 2024-09-28T18:58:22.556099Z

For example:

(s/fdef jdbc/with-transaction
  :args (s/cat :binding (s/and vector?
                               (s/cat :sym simple-symbol?
                                      :transactable ::transactable
                                      :opts (s/? any?)))
               :body (s/* any?)))
for
(defmacro with-transaction
  "..."
  [[sym transactable opts] & body]
  (let [con (vary-meta sym assoc :tag 'java.sql.Connection)]
   `(transact ~transactable (^{:once true} fn* [~con] ~@body) ~(or opts {}))))

2024-09-28T19:34:12.365249Z

Thank you, Sean