(=> & args+rets)Create a spec definition for a function. The syntax is as follows:
(=> [args*] ret) ; single-clause
(=> [args1*] ret1, [args2*] ret2, ...) ; multi-clause
s/?) arguments can be used; then the number of
argument specs must match the number of args in the largest arity of
the function. For variable arity functions, the last argument
spec (presumably defined with s/*) is matched with the list of
varargs.This macro does not register the spec definition of which it
creates; for that, you must add the definition as :speck metadata
of the corresponding function, and then call gen-spec or
gen-specs-in-ns.
Create a spec definition for a function. The syntax is as follows:
(=> [args*] ret) ; single-clause
(=> [args1*] ret1, [args2*] ret2, ...) ; multi-clause
- where args and rets represent specs. Each of the args will be
matched with the argument it checks based on the order of the
arguments in the fn's arglists. For multi-arity functions,
multi-clause form can be used, and different ret specs can be
specified for each arity. Alternatively, single-clause form with
optional (via `s/?`) arguments can be used; then the number of
argument specs must match the number of args in the largest arity of
the function. For variable arity functions, the last argument
spec (presumably defined with `s/*`) is matched with the list of
varargs.
This macro does not register the spec definition of which it
creates; for that, you must add the definition as :speck metadata
of the corresponding function, and then call `gen-spec` or
`gen-specs-in-ns`.(gen-spec sym)Generate and define (via clojure.spec.alpha/fdef) a spec for the
specked function named by sym. A function is specked when it
contains :clojure.spec.alpha/def key in its metadata, with the value
being the output of => or |. Usually you should prefer
gen-specs-in-ns to calling this directly.
Generate and define (via `clojure.spec.alpha/fdef`) a spec for the specked function named by sym. A function is specked when it contains :clojure.spec.alpha/def key in its metadata, with the value being the output of `=>` or `|`. Usually you should prefer `gen-specs-in-ns` to calling this directly.
(gen-specs-in-ns)Generate and define specs (via gen-spec) for every specked
function in the current ns. You should put a call to this macro at
the end of your file, after all of the functions in the ns has been
defined. Note that this does NOT instrument your functions - you
should do it yourself with clojure.spec.test.alpha/instrument or
orchestra.spec.test/instrument.
Generate and define specs (via `gen-spec`) for every specked function in the current ns. You should put a call to this macro at the end of your file, after all of the functions in the ns has been defined. Note that this does NOT instrument your functions - you should do it yourself with `clojure.spec.test.alpha/instrument` or `orchestra.spec.test/instrument`.
(| & body)Syntax sugar for =>.
(| args* => ret, ...) desugars to (=> [args] ret, ...). You can use
_ in place of an empty argument vector. Note that the arrow =>
inside the body of this macro is part of the syntax and is not the
same as the macro =>.
Syntax sugar for `=>`. (| args* => ret, ...) desugars to (=> [args] ret, ...). You can use _ in place of an empty argument vector. Note that the arrow => inside the body of this macro is part of the syntax and is not the same as the macro `=>`.
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 |