GitHub

compiler

API reference for compiler.

The shared registry of schema decoders (Effect's SchemaCompiler).

A decoder installed with set for an exact AST is used by every parser (S.decode_unknown_sync, S.is_, Bottom.make, ...) and by every schema that reaches the AST, without a compiled schema type or a second parser API. The JIT compiler (pyfect.schema.jit_compiler) and modules written by the ahead-of-time compiler (pyfect.schema.aot_compiler) fill the same registry.

An installed decoder (a CompiledDecoder, or any object with these attributes) has decode_effect, the complete decoder, and may have the fast paths is_, decode and make, which return INVALID for an invalid input (is_ returns False), and make_effect, the complete constructor. Each attribute is read once, when first needed. Parsers that already resolved an AST keep its entry after a later set.

Re-exports

Values

AttributeTypeDescription
DEFAULT_PARSE_OPTIONSFinal[ParseOptions] = {}

The options of a call that gives none (Effect's defaultParseOptions): this same object, so an operation can tell.

INVALIDInvalid

What a fast path (is aside) returns for an invalid input (Effect's SchemaCompiler.invalid).

Types

TypeDefinitionDescription
Decodetype Decode = Callable[[object, ParseOptions], object]

The decoded value, or INVALID.

DecodeEffecttype DecodeEffect = Parser
Istype Is = Callable[[object, ParseOptions], bool]
Maketype Make = Callable[[object, ParseOptions], object]
MakeEffecttype MakeEffect = Parser

Classes

Functions

set

set(ast, decoder) -> None

Install decoder for ast (Effect's SchemaCompiler.set). A later set replaces it for parsers that have not resolved ast yet; the decoder is trusted to implement the AST's semantics.

ParameterTypeDescription
astAST
decoderDecoderSource
def set(ast: AST, decoder: DecoderSource, /) -> None:
    """Install ``decoder`` for ``ast`` (Effect's ``SchemaCompiler.set``). A
    later ``set`` replaces it for parsers that have not resolved ``ast``
    yet; the decoder is trusted to implement the AST's semantics."""
    _set(ast, decoder)

Modules