Liking cljdoc? Tell your friends :D

meme.alpha.pipeline.contract

Formal contract for the meme pipeline context map.

Defines clojure.spec.alpha specs for the context at each stage boundary, a toggleable runtime validator, and explain functions for debugging.

The pipeline is composable ctx → ctx stages:

scan → parse → expand

Context map contract:

KeyTypeWritten byRead by
:sourceStringcallerscan, parse
:optsMap or nilcallerparse, expand
:raw-tokensVectorscan(tooling)
:tokensVectorscanparse
:formsVectorparse, expandexpand, caller

Guest languages that replace stages (e.g. a custom parser that reads :tokens and writes :forms) must produce context maps conforming to the relevant stage-output spec. Enable runtime validation during development:

(binding [contract/validate true] (pipeline/run source))

Formal contract for the meme pipeline context map.

Defines clojure.spec.alpha specs for the context at each stage boundary,
a toggleable runtime validator, and explain functions for debugging.

The pipeline is composable ctx → ctx stages:

  scan → parse → expand

Context map contract:

| Key          | Type           | Written by    | Read by              |
|--------------|----------------|---------------|----------------------|
| :source      | String         | caller        | scan, parse          |
| :opts        | Map or nil     | caller        | parse, expand        |
| :raw-tokens  | Vector         | scan          | (tooling)            |
| :tokens      | Vector         | scan          | parse                |
| :forms       | Vector         | parse, expand | expand, caller       |

Guest languages that replace stages (e.g. a custom parser that reads
:tokens and writes :forms) must produce context maps conforming to
the relevant stage-output spec. Enable runtime validation during
development:

  (binding [contract/*validate* true]
    (pipeline/run source))
raw docstring

*validate*clj/s

When true, pipeline stages validate their input and output context maps against the formal contract. Default: false (zero overhead). Bind to true for development, testing, or debugging guest parsers.

Example: (binding [contract/validate true] (pipeline/run source))

When true, pipeline stages validate their input and output context maps
against the formal contract. Default: false (zero overhead).
Bind to true for development, testing, or debugging guest parsers.

Example:
  (binding [contract/*validate* true]
    (pipeline/run source))
sourceraw docstring

explain-contextclj/s

(explain-context stage phase ctx)

Return a human-readable explanation of why ctx fails the contract for the given stage and phase (:input or :output). Returns nil if ctx is valid. Not gated by validate.

Useful for tooling, REPL debugging, and guest language development.

Return a human-readable explanation of why ctx fails the contract
for the given stage and phase (:input or :output).
Returns nil if ctx is valid. Not gated by *validate*.

Useful for tooling, REPL debugging, and guest language development.
sourceraw docstring

stage-input-specclj/s

Map from stage keyword to the spec its input context must satisfy.

Map from stage keyword to the spec its input context must satisfy.
sourceraw docstring

stage-output-specclj/s

Map from stage keyword to the spec its output context must satisfy.

Map from stage keyword to the spec its output context must satisfy.
sourceraw docstring

token-typesclj/s

All token types emitted by the meme tokenizer.

All token types emitted by the meme tokenizer.
sourceraw docstring

valid?clj/s

(valid? stage phase ctx)

Check if ctx satisfies the contract for the given stage and phase. Does not throw. Not gated by validate.

Check if ctx satisfies the contract for the given stage and phase.
Does not throw. Not gated by *validate*.
sourceraw docstring

validate!clj/s

(validate! stage phase ctx)

Validate ctx against the contract for the given stage and phase. Throws ex-info with :stage, :phase, and :problems when validate is true and ctx fails spec. No-op when validate is false.

Called automatically by pipeline stages when validate is true. Can also be called directly by guest language parsers.

Validate ctx against the contract for the given stage and phase.
Throws ex-info with `:stage`, `:phase`, and `:problems` when
*validate* is true and ctx fails spec. No-op when *validate* is false.

Called automatically by pipeline stages when *validate* is true.
Can also be called directly by guest language parsers.
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