Liking cljdoc? Tell your friends :D

defn-typed.typed-clojure

Typed Clojure checks of defn-typed code, with the types the signatures already declare: no hand-written annotation per function. Optional: the library does not depend on Typed Clojure; require this namespace only with org.typedclojure/typed.clj.checker and org.typedclojure/typed.malli on the classpath.

  • install! makes the checker know every defn-typed function of the given namespaces: the function itself through typed.malli's var-type provider (which reads malli's function schemas, so it collects them), <name>--positional (where the body lives) and <name>-props through generated t/ann forms, and the defn-typed.core vars a checked expansion calls;
  • install-fn! does the same for one function;
  • check-form! checks one top-level form without evaluating it and returns its type errors as data, each marked whether it involves a defn-typed function;
  • could-not-type? tells a message saying the checker could not type the code from a type error. A function with type variables ((defn-typed f [T] {:xs [:sequential T]} -> [:maybe T] …)) is annotated (t/All [T] …), the function and its <name>--positional alike. Loading this namespace also teaches typed.malli the malli [:tuple …] schema: (t/HVec [<item types>]) (typed.malli alone types it t/Any). defn-typed.core loads this namespace itself when Typed Clojure is on the classpath: each defn-typed definition is then checked as it loads (:typed-check in defn-typed.edn).
Typed Clojure checks of defn-typed code, with the types the signatures already declare: no
hand-written annotation per function. Optional: the library does not depend on Typed Clojure;
require this namespace only with `org.typedclojure/typed.clj.checker` and
`org.typedclojure/typed.malli` on the classpath.

- `install!` makes the checker know every defn-typed function of the given namespaces: the
  function itself through typed.malli's var-type provider (which reads malli's function
  schemas, so it collects them), `<name>--positional` (where the body lives) and `<name>-props`
  through generated `t/ann` forms, and the defn-typed.core vars a checked expansion calls;
- `install-fn!` does the same for one function;
- `check-form!` checks one top-level form without evaluating it and returns its type errors
  as data, each marked whether it involves a defn-typed function;
- `could-not-type?` tells a message saying the checker could not type the code from a type error.
A function with type variables (`(defn-typed f [T] {:xs [:sequential T]} -> [:maybe T] …)`) is annotated
`(t/All [T] …)`, the function and its `<name>--positional` alike. Loading this namespace also
teaches typed.malli the malli `[:tuple …]` schema: `(t/HVec [<item types>])` (typed.malli alone
types it `t/Any`).
defn-typed.core loads this namespace itself when Typed Clojure is on the classpath: each
defn-typed definition is then checked as it loads (`:typed-check` in defn-typed.edn).
raw docstring

check-form!clj

(check-form! {:keys [ns form file]})

Type-checks one top-level form of the namespace ns (loaded, install!ed) without evaluating it (:check-form-eval :never: the default re-evaluates the form, which drops malli's instrumentation of what it redefines). file = the source path the errors name. Returns every type error: {:file :line :column :message :kind :defn-typed?}: :message = the checker's text, led by input of <f>: when it could not apply the defn-typed function f to the call's map (:kind :input) or by output of <f>: for a type mismatch in the defn-typed definition of f (:kind :output), :kind nil otherwise; :defn-typed? true when the error is inside a (defn-typed …) / (defnt …) form (its body) or its form calls a defn-typed function. A checker crash (StackOverflowError on a very large form) is one error of its message.

Type-checks one top-level `form` of the namespace `ns` (loaded, `install!`ed) without
evaluating it (`:check-form-eval :never`: the default re-evaluates the form, which drops
malli's instrumentation of what it redefines). `file` = the source path the errors name.
Returns every type error: `{:file :line :column :message :kind :defn-typed?}`: `:message`
= the checker's text, led by `input of <f>: ` when it could not apply the defn-typed
function f to the call's map (`:kind :input`) or by `output of <f>: ` for a type mismatch
in the defn-typed definition of f (`:kind :output`), `:kind` nil otherwise; `:defn-typed?`
true when the error is inside a `(defn-typed …)` / `(defnt …)` form (its body) or its form calls a
defn-typed function. A checker crash (StackOverflowError on a very large form) is one
error of its message.
sourceraw docstring

check-form!-propsclj

source

could-not-typeclj

Checker messages that say Typed Clojure could not type the code, not that the code has a type error, so defn-typed.core drops them from its definition check (and a tool reporting checker findings can drop them the same way, through could-not-type?):

  • Unannotated var … — the code calls a var the checker has no type for (a plain defn of the project, a library fn without annotations);
  • Loop requires more annotations — a loop whose binding types it cannot infer;
  • Missing type for binding: … — a binding of a dynamic var it has no type for.
Checker messages that say Typed Clojure could not type the code, not that the code has a type
error, so defn-typed.core drops them from its definition check (and a tool reporting checker
findings can drop them the same way, through could-not-type?):
- `Unannotated var …` — the code calls a var the checker has no type for (a plain defn of the
  project, a library fn without annotations);
- `Loop requires more annotations` — a loop whose binding types it cannot infer;
- `Missing type for binding: …` — a `binding` of a dynamic var it has no type for.
sourceraw docstring

could-not-type?clj

(could-not-type? message)

Whether a checker message (check-form!'s :message, its input of/output of label included) is one of could-not-type.

Whether a checker message (check-form!'s `:message`, its `input of`/`output of` label
included) is one of could-not-type.
sourceraw docstring

install!clj

(install! {:keys [namespaces]})

Makes Typed Clojure know every defn-typed function of namespaces (loaded symbols): judges their schemas first (check-var-schemas!: one malli cannot build throws one line naming the function, the row or the output, and the file:line), then collects their malli function schemas (typed.malli's var-type provider, registered by its typedclojure_config on the classpath, types each function from them) and evaluates the t/ann forms of their <name>--positional / <name>--body and <name>-props, and of the defn-typed.core vars a checked expansion calls. Run it again after a namespace is reloaded. Returns the number of t/ann forms evaluated.

Makes Typed Clojure know every defn-typed function of `namespaces` (loaded symbols): judges
their schemas first (check-var-schemas!: one malli cannot build throws one line naming
the function, the row or the output, and the file:line), then collects their malli
function schemas (typed.malli's var-type provider, registered by its
typedclojure_config on the classpath, types each function from them) and evaluates the
`t/ann` forms of their `<name>--positional` / `<name>--body` and `<name>-props`, and of
the defn-typed.core vars a checked expansion calls. Run it again after a namespace is
reloaded. Returns the number of `t/ann` forms evaluated.
sourceraw docstring

install!-propsclj

source

install-fn!clj

(install-fn! {:keys [fn-var]})

install! for the one defn-typed function held by fn-var: judges its schemas (check-var-schemas!), collects its malli function schema and evaluates the t/ann forms of its <name>--positional / <name>--body and <name>-props, and of the defn-typed.core vars a checked expansion calls. What defn-typed.core runs right after a definition it type-checks. Returns the number of t/ann forms evaluated (those of the defn-typed.core vars only, when fn-var is not a defn-typed function).

install! for the one defn-typed function held by `fn-var`: judges its schemas
(check-var-schemas!), collects its malli function schema and evaluates the `t/ann` forms
of its `<name>--positional` / `<name>--body` and `<name>-props`, and of the
defn-typed.core vars a checked expansion calls. What defn-typed.core runs right after a
definition it type-checks. Returns the number of
`t/ann` forms evaluated (those of the defn-typed.core vars only, when fn-var is not a
defn-typed function).
sourceraw docstring

install-fn!-propsclj

source

lib-annsclj

defn-typed.core vars a checked expansion calls: row-value (the binding of a row read at call time) and register-tests! (the legacy tests). Trusted, not checked (^:no-check).

defn-typed.core vars a checked expansion calls: `row-value` (the binding of a row read at call
time) and `register-tests!` (the legacy `tests`). Trusted, not checked (`^:no-check`).
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close