        ~@body)))
 
 (defmacro with-query-bindings
-  "Takes a query, a query result and an arbitrary code block.
+  "Takes a `query`, a query `result` and an arbitrary code `body`.
    Wraps the code block so that all possible bindings derived
    from the query are bound to the values in the query result."
   [query result & body]

  :ret ::core-specs/map-bindings)

(defn query-bindings
  "Takes a query or parsed query and returns map bindings to
   be applied to the corresponding query result in order to
   destructure and bind all possible properties in the query
   result to their names.

   E.g. for a query [a :as b c [d e {f [g :as h]}]] it
   would return {b :a, d :c/d, e :c/e, f :f, {{h :g} :f}}."
  [query]
  (let [paths    (binding-paths query)
        bindings (mapv path-bindings paths)

  :ret ::sb/paths)

(defn binding-paths
  "Returns a vector of all property binding paths for a `query`
   or parsed query."
  [query]
  (transduce (map property-binding-paths) concat []
