Liking cljdoc? Tell your friends :D

beichte.effect

Effect lattice and feature flags for static effect inference.

State effect lattice (total order)

:pure < :local < :mutation < :io

  • :pure — no side effects, safe for AD, CSE, GPU, parallelization
  • :local — thread-local mutation (transients, volatiles, loop scratch) safe for parallelization/GPU, not for AD/CSE
  • :mutation — global mutable state (atoms, refs, vars) only safe for sequential execution
  • :io — external I/O (println, file ops, network, system calls) only safe for sequential, cannot reorder

The join (least upper bound) of two effects is their maximum. Effect inference propagates the join through the call graph.

Feature flags (orthogonal to state effects)

Feature flags capture properties that are independent of the state effect ordering:

  • :throws — may throw exceptions (partial function)
  • :random — uses randomness (nondeterministic)
  • :reflects — uses reflection (cannot AOT / cannot optimize)
  • :allocates — heap allocates (relevant for real-time / GPU scratch)

Flags propagate via set union through the call graph. Compilation targets can declare which flags they tolerate.

Effect lattice and feature flags for static effect inference.

## State effect lattice (total order)

  :pure < :local < :mutation < :io

- :pure      — no side effects, safe for AD, CSE, GPU, parallelization
- :local     — thread-local mutation (transients, volatiles, loop scratch)
                safe for parallelization/GPU, not for AD/CSE
- :mutation  — global mutable state (atoms, refs, vars)
                only safe for sequential execution
- :io        — external I/O (println, file ops, network, system calls)
                only safe for sequential, cannot reorder

The join (least upper bound) of two effects is their maximum.
Effect inference propagates the join through the call graph.

## Feature flags (orthogonal to state effects)

Feature flags capture properties that are independent of the state
effect ordering:

- :throws    — may throw exceptions (partial function)
- :random    — uses randomness (nondeterministic)
- :reflects  — uses reflection (cannot AOT / cannot optimize)
- :allocates — heap allocates (relevant for real-time / GPU scratch)

Flags propagate via set union through the call graph.
Compilation targets can declare which flags they tolerate.
raw docstring

<=effectclj

(<=effect a b)

True if effect a is at most as effectful as b.

True if effect a is at most as effectful as b.
sourceraw docstring

budget-forclj

(budget-for target)

Return the maximum allowed effect level for a compilation target.

Return the maximum allowed effect level for a compilation target.
sourceraw docstring

compilable?clj

(compilable? target desc)
(compilable? target desc custom-unsupported)

True if an effect descriptor is compatible with a compilation target. Checks both the state effect budget and feature flag support.

True if an effect descriptor is compatible with a compilation target.
Checks both the state effect budget and feature flag support.
sourceraw docstring

effectclj

(effect level)
(effect level flags)

Create an effect descriptor: {:effect level, :flags #{...}}. Shorthand: (effect :pure) or (effect :local #{:throws}).

Create an effect descriptor: {:effect level, :flags #{...}}.
Shorthand: (effect :pure) or (effect :local #{:throws}).
sourceraw docstring

effect-joinclj

(effect-join a b)

Join two effect descriptors (component-wise max / union).

Join two effect descriptors (component-wise max / union).
sourceraw docstring

effect-join-allclj

(effect-join-all descs)
(effect-join-all init descs)

Join a collection of effect descriptors.

Join a collection of effect descriptors.
sourceraw docstring

flags-joinclj

(flags-join a b)

Union of two flag sets.

Union of two flag sets.
sourceraw docstring

joinclj

(join a b)

Least upper bound of two effects (their maximum).

Least upper bound of two effects (their maximum).
sourceraw docstring

join-allclj

(join-all effs)
(join-all init effs)

Least upper bound of a collection of effects.

Least upper bound of a collection of effects.
sourceraw docstring

known-flagsclj

Known feature flags.

Known feature flags.
sourceraw docstring

level-indexclj

(level-index eff)

Return the ordinal index of an effect level.

Return the ordinal index of an effect level.
sourceraw docstring

levelsclj

Effect levels in ascending order.

Effect levels in ascending order.
sourceraw docstring

pureclj

The pure effect descriptor (no effects, no flags).

The pure effect descriptor (no effects, no flags).
sourceraw docstring

unsupported-flags-forclj

(unsupported-flags-for target)
(unsupported-flags-for target custom-map)

Return the set of feature flags unsupported by a compilation target. Can be overridden by providing a custom map.

Return the set of feature flags unsupported by a compilation target.
Can be overridden by providing a custom map.
sourceraw docstring

valid-flag?clj

(valid-flag? flag)

True if flag is a recognized feature flag.

True if flag is a recognized feature flag.
sourceraw docstring

within-budget?clj

(within-budget? budget eff)

True if the given effect level is within the budget. A budget is an effect level; anything at or below it is acceptable.

Common budgets: :pure — only pure code (AD, CSE) :local — allow thread-local mutation (GPU, parallel) :mutation — allow global mutation (sequential, inlining) :io — allow everything

True if the given effect level is within the budget.
A budget is an effect level; anything at or below it is acceptable.

Common budgets:
  :pure     — only pure code (AD, CSE)
  :local    — allow thread-local mutation (GPU, parallel)
  :mutation — allow global mutation (sequential, inlining)
  :io       — allow everything
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