Skip to content

Commit

Permalink
-loc
Browse files Browse the repository at this point in the history
  • Loading branch information
ikitommi committed Feb 4, 2023
1 parent cab4fbf commit d85b49b
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/malli/experimental.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
(def Params (-schema false))

(c/defn -defn [schema args]
(let [{:keys [name return doc arities]
body-meta :meta
:as parsed} (m/parse schema args)
(let [{:keys [name return doc arities] body-meta :meta :as parsed} (m/parse schema args)
var-meta (meta name)
_ (when (= ::m/invalid parsed) (m/-fail! ::parse-error {:schema schema, :args args}))
parse (fn [{:keys [args] :as parsed}] (merge (md/parse args) parsed))
Expand All @@ -48,18 +46,15 @@
raw-arglists (map :raw-arglist parglists)
schema (as-> (map ->schema parglists) $ (if single (first $) (into [:function] $)))
bodies (map (fn [{:keys [arglist prepost body]}] `(~arglist ~prepost ~@body)) parglists)
validate? (or (:malli/always var-meta)
(:malli/always body-meta))
validate? (or (:malli/always var-meta) (:malli/always body-meta))
enriched-meta (assoc body-meta :raw-arglists (list 'quote raw-arglists) :schema schema)]
`(let [defn# ~(if validate?
`(def
~(with-meta name (merge var-meta
enriched-meta
{:arglists (list 'quote (map :arglist parglists))}))
~@(some-> doc vector)
(m/-instrument
{:schema ~schema}
(fn ~(gensym (str name "-instrumented")) ~@bodies)))
(m/-instrument {:schema ~schema} (fn ~(gensym (str name "-instrumented")) ~@bodies)))
`(c/defn
~name
~@(some-> doc vector)
Expand Down

0 comments on commit d85b49b

Please sign in to comment.