Support for making function specs DRYer to write.
Support for making function specs DRYer to write.
(=> f parameter-specs return-spec & more)
Define a typed function or redefine an existing function to be typed.
The function's name and type signature are first. If nothing else follows, the specified function must already exist and it will be redefined with the pre/post conditions specified by the parameter specs and return spec. If a function definition (in defn form) follows, emits new defn containing pre/post conditions as specified by the parameter specs and return spec.
The metadata map is supplied by this macro and cannot currently be overridden/supplemented. Only handles a single argument list.
In all cases, includes the derived function type in the function's docstring.
f - The function to define.
parameter-specs - A vector of the specs to use to validate each (destructured) argument. For example, if the argument list is [[x y] color] then the parameter spec must have three elements, corresponding to x, y, and color. e.g.: [number? number? keyword?] The parameter spec is always flattened, with the arguments listed in the order in which they appear in the parameter list.
return-spec - A spec to validate the return value.
more - If present, in the form: docstring? [arglist-vector] & statements. If empty, then annotates an existing function f with a type defined by parameter-specs => return-spec.
Define a typed function or redefine an existing function to be typed. The function's name and type signature are first. If nothing else follows, the specified function must already exist and it will be redefined with the pre/post conditions specified by the parameter specs and return spec. If a function definition (in defn form) follows, emits new defn containing pre/post conditions as specified by the parameter specs and return spec. The metadata map is supplied by this macro and cannot currently be overridden/supplemented. Only handles a single argument list. In all cases, includes the derived function type in the function's docstring. f - The function to define. parameter-specs - A vector of the specs to use to validate each (destructured) argument. For example, if the argument list is [[x y] color] then the parameter spec must have three elements, corresponding to x, y, and color. e.g.: [number? number? keyword?] The parameter spec is always flattened, with the arguments listed in the order in which they appear in the parameter list. return-spec - A spec to validate the return value. more - If present, in the form: docstring? [arglist-vector] & statements. If empty, then annotates an existing function f with a type defined by parameter-specs => return-spec.
(annotate-fn f parameter-specs return-spec)
Rename the existing f; make a new f with type checking/docs; delegate to the renamed f.
Rename the existing f; make a new f with type checking/docs; delegate to the renamed f.
(args f)
Return f's argument lists. Public for testability only.
Return f's argument lists. Public for testability only.
(resolved sym)
Returns the resolved var for sym; i.e.: sym -> #'sym
Returns the resolved var for sym; i.e.: sym -> #'sym
(typed-fn f parameter-specs return-spec more)
Return a defn statement with :pre and :post conditions using specs to typecheck parameters and return value.
Return a defn statement with :pre and :post conditions using specs to typecheck parameters and return value.
(validations symbols specs symbols-str)
public for testability only
public for testability only
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close