Typed definitions. (defurpx kind name doc? value) defs name to
value after validating the value against (kind-schema kind); the var
carries the kind, so defs-of-kind finds every definition of a kind in
the namespaces a caller names.
(defmethod defs/kind-schema :ex/rates [_] [:map-of :keyword decimal?])
(defs/defurpx :ex/rates rtc-rates "Cents per kWh." {:peak 16.10M :off-peak 8.05M})
(defs/defs-of-kind :ex/rates ['my.corpus]) ; => [#'my.corpus/rtc-rates]
The urpx.kind namespace is reserved for kinds clj-urpx defines; a
library or corpus qualifies its kinds in its own namespace.
Typed definitions. `(defurpx kind name doc? value)` defs `name` to
`value` after validating the value against `(kind-schema kind)`; the var
carries the kind, so `defs-of-kind` finds every definition of a kind in
the namespaces a caller names.
(defmethod defs/kind-schema :ex/rates [_]
[:map-of :keyword decimal?])
(defs/defurpx :ex/rates rtc-rates
"Cents per kWh."
{:peak 16.10M :off-peak 8.05M})
(defs/defs-of-kind :ex/rates ['my.corpus]) ; => [#'my.corpus/rtc-rates]
The `urpx.kind` namespace is reserved for kinds clj-urpx defines; a
library or corpus qualifies its kinds in its own namespace.(defs-of-kind kind nses)The vars interned in namespaces nses (namespaces or symbols) whose
metadata names kind as their :urpx/kind, sorted by symbol.
The vars interned in namespaces `nses` (namespaces or symbols) whose metadata names `kind` as their `:urpx/kind`, sorted by symbol.
(defurpx kind name & body)(defurpx kind name doc? value): def name to value, with var metadata
{:urpx/kind kind}, the docstring, :file and :line.
kind must be a keyword literal. At macroexpansion an unknown kind
throws, then the value form is evaluated and validated with validate!,
so an invalid value throws before the def, and a failed re-evaluation
leaves an existing var as it was. The def evaluates the value form
again.
(defurpx kind name doc? value): def `name` to `value`, with var metadata
`{:urpx/kind kind}`, the docstring, `:file` and `:line`.
`kind` must be a keyword literal. At macroexpansion an unknown kind
throws, then the value form is evaluated and validated with `validate!`,
so an invalid value throws before the `def`, and a failed re-evaluation
leaves an existing var as it was. The `def` evaluates the value form
again.The Malli schema a defurpx of kind must satisfy. A method is added
per kind; the :default method refuses.
The Malli schema a `defurpx` of `kind` must satisfy. A method is added per kind; the `:default` method refuses.
(validate! kind value where)value if it satisfies (kind-schema kind) with every map in the schema
closed (a map that says {:closed false} stays open, and a map reached
through a :ref keeps its own :closed property). Otherwise throws
ex-info whose message names kind and the definition at where (a map
of :ns, :name, :file and :line), then one line per failing Malli
:in path; the ex-data carries :kind, :where and the humanized
:errors.
`value` if it satisfies `(kind-schema kind)` with every map in the schema
closed (a map that says `{:closed false}` stays open, and a map reached
through a `:ref` keeps its own `:closed` property). Otherwise throws
ex-info whose message names `kind` and the definition at `where` (a map
of `:ns`, `:name`, `:file` and `:line`), then one line per failing Malli
`:in` path; the ex-data carries `:kind`, `:where` and the humanized
`:errors`.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |