Effect inference via AST walking.
Performs lightweight abstract interpretation over the effect lattice: walks the tools.analyzer.jvm AST and infers the effect level and feature flags of each node by propagating the join through the call graph.
The analysis is modular: it uses an immutable registry for ground truth and maintains a mutable cache for recursive var analysis. The cache is per-analysis-session, not global.
Two inference modes:
infer-effect — returns bare effect level (:pure, :local, etc.)infer-descriptor — returns full descriptor {:effect :level :flags #{...}}Effect inference via AST walking.
Performs lightweight abstract interpretation over the effect lattice:
walks the tools.analyzer.jvm AST and infers the effect level and
feature flags of each node by propagating the join through the call
graph.
The analysis is modular: it uses an immutable registry for ground
truth and maintains a mutable cache for recursive var analysis.
The cache is per-analysis-session, not global.
Two inference modes:
- `infer-effect` — returns bare effect level (:pure, :local, etc.)
- `infer-descriptor` — returns full descriptor {:effect :level :flags #{...}}(analyze-expr expr)(analyze-expr expr opts)Analyze an S-expression and return its effect level. For full descriptors with flags, use analyze-expr-full.
opts may include: :analysis — reuse a context from make-analysis (for caching) :registry — custom registry (ignored if :analysis given) :ns — namespace context (default: ns)
Analyze an S-expression and return its effect level. For full descriptors with flags, use analyze-expr-full. opts may include: :analysis — reuse a context from make-analysis (for caching) :registry — custom registry (ignored if :analysis given) :ns — namespace context (default: *ns*)
(analyze-expr-full expr)(analyze-expr-full expr opts)Analyze an S-expression and return its full effect descriptor. Returns {:effect :level, :flags #{...}}.
Analyze an S-expression and return its full effect descriptor.
Returns {:effect :level, :flags #{...}}.(analyze-ns ns-sym)(analyze-ns ns-sym opts)Analyze all public vars in a namespace and return a map of {var -> effect}.
Analyze all public vars in a namespace and return a map of {var -> effect}.
(analyze-ns-full ns-sym)(analyze-ns-full ns-sym opts)Analyze all public vars and return {var -> descriptor}.
Analyze all public vars and return {var -> descriptor}.
(analyze-var v)(analyze-var v opts)Analyze a var and return its effect level.
Analyze a var and return its effect level.
(analyze-var-full v)(analyze-var-full v opts)Analyze a var and return its full effect descriptor.
Analyze a var and return its full effect descriptor.
(compilable? target expr)(compilable? target expr opts)Check if an expression is within the effect budget for a compilation target. Uses full descriptor analysis (checks both state effects and feature flags).
Check if an expression is within the effect budget for a compilation target. Uses full descriptor analysis (checks both state effects and feature flags).
(filter-compilable target vars)(filter-compilable target vars opts)Filter a collection of vars to those compilable for a target.
Filter a collection of vars to those compilable for a target.
(infer-descriptor analysis ast)(infer-descriptor analysis visited ast)Infer the full effect descriptor of an AST node. Returns {:effect :level, :flags #{...}}
Infer the full effect descriptor of an AST node.
Returns {:effect :level, :flags #{...}}(infer-effect analysis ast)(infer-effect analysis visited ast)Infer the effect level of an AST node. Returns one of: :pure, :local, :mutation, :io
Infer the effect level of an AST node. Returns one of: :pure, :local, :mutation, :io
(make-analysis)(make-analysis registry)Create a fresh analysis state.
Create a fresh analysis state.
- registry: immutable map of known effects (level or descriptor)
- cache: atom of {entry -> effect-level}, populated during analysis(source-var v)Retrieve the source code string for a var from classpath or filesystem. Returns the source string, or nil if unavailable.
Retrieve the source code string for a var from classpath or filesystem. Returns the source string, or nil if unavailable.
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 |