hydra.overlay.python.sources.libraries module

Python primitive registration functions.

Primitive names are derived from the generated hydra.lib.* PrimitiveDefinition def-modules (via def_<sub>.<fn>.name) — the single source of truth for primitive names (#473) — rather than hand-written name strings. Signatures remain explicit here because the registry must present each primitive’s type to the interpreter in native type-coder form.

hydra.overlay.python.sources.libraries.fun(dom, cod)

A TermCoder for function types which uses beta reduction to bridge term-level functions to native functions. This allows higher-order primitives like map, filter, foldl, etc. to use native implementations rather than eval-level ones.

hydra.overlay.python.sources.libraries.register_chars_primitives() dict[Name, Primitive]

Register all chars primitive functions.

hydra.overlay.python.sources.libraries.register_default_fallback_primitives(already_native: dict[Name, Primitive]) dict[Name, Primitive]

Register primitives which have no native Python implementation, but do declare a portable defaultImplementation term in the kernel (see hydra.lib.defaults.default_implementations()). Each is registered via prims.default_fallback_primitive, which evaluates the default term via reduce_term rather than running Python logic.

Spike (#609 Stage 3): only lists.takeWhile is wired here, mirroring the Java validation case (#609 Stage 2). Once confirmed here, the remaining 11 Group-A primitives are wired the same way.

hydra.overlay.python.sources.libraries.register_effects_primitives() dict[Name, Primitive]

Register all effects primitive functions. In Python the effect type is transparent (effect<t> = t), so these have no term-level interpreter implementation; they are registered for name resolution and inference only. For #494.

hydra.overlay.python.sources.libraries.register_eithers_primitives() dict[Name, Primitive]

Register all eithers primitive functions.

hydra.overlay.python.sources.libraries.register_equality_primitives() dict[Name, Primitive]

Register all equality primitive functions.

hydra.overlay.python.sources.libraries.register_files_primitives() dict[Name, Primitive]

Register all files primitive functions. As effectful primitives, these have no term-level interpreter implementation; they are registered for name resolution and inference only, and are executed via the native (host) path. For #494.

hydra.overlay.python.sources.libraries.register_functions_primitives() dict[Name, Primitive]

Register all functions primitive functions. absurd/identity are provided natively; compose/const/flip carry kernel default implementations and need no overlay. For #417.

hydra.overlay.python.sources.libraries.register_hashing_primitives() dict[Name, Primitive]

Register all hashing primitive functions (SHA-256). Pure and total. For #524.

hydra.overlay.python.sources.libraries.register_lists_primitives() dict[Name, Primitive]

Register all list primitive functions.

hydra.overlay.python.sources.libraries.register_literals_primitives() dict[Name, Primitive]

Register all literals primitive functions.

hydra.overlay.python.sources.libraries.register_logic_primitives() dict[Name, Primitive]

Register all logic primitive functions.

hydra.overlay.python.sources.libraries.register_maps_primitives() dict[Name, Primitive]

Register all map primitive functions.

hydra.overlay.python.sources.libraries.register_math_primitives() dict[Name, Primitive]

Register all math primitive functions.

hydra.overlay.python.sources.libraries.register_optionals_primitives() dict[Name, Primitive]

Register all optional primitive functions.

hydra.overlay.python.sources.libraries.register_ordering_primitives() dict[Name, Primitive]

Register all ordering primitive functions. For #417.

hydra.overlay.python.sources.libraries.register_pairs_primitives() dict[Name, Primitive]

Register all pairs primitive functions.

hydra.overlay.python.sources.libraries.register_regex_primitives() dict[Name, Primitive]

Register all regex primitive functions.

hydra.overlay.python.sources.libraries.register_sets_primitives() dict[Name, Primitive]

Register all set primitive functions.

hydra.overlay.python.sources.libraries.register_strings_primitives() dict[Name, Primitive]

Register all string primitive functions.

hydra.overlay.python.sources.libraries.register_system_primitives() dict[Name, Primitive]

Register all system primitive functions. As effectful primitives, these have no term-level interpreter implementation; they are registered for name resolution and inference only, and are executed via the native (host) path. For #498.

hydra.overlay.python.sources.libraries.register_text_primitives() dict[Name, Primitive]

Register all text primitive functions (UTF-8 codecs). For #494.

hydra.overlay.python.sources.libraries.standard_library() dict[Name, Primitive]

Get all standard library primitives.

hydra.overlay.python.sources.libraries.unsupported_effect_primitive(definition) Primitive

Register an effect primitive for name resolution and inference, while keeping Hydra’s pure reducer from interpreting host effects as ordinary terms. Mirrors the Haskell unsupportedEffectPrimitive: the type scheme is taken directly from the def-module’s PrimitiveDefinition (the single source of truth), and the term-level implementation fails loudly, since effect primitives are evaluated through the native (host) path, not the interpreter. For #494.