hydra.encoding module
Functions for generating term encoders from type modules.
- hydra.encoding.encode_binding(cx: T0, graph: Graph, b: Binding) object
Transform a type binding into an encoder binding.
- hydra.encoding.encode_binding_name(v1: Name) Name
Generate a binding name for an encoder function from a type name.
- hydra.encoding.encode_either_type(et: EitherType) Term
Generate an encoder for an Either type.
- hydra.encoding.encode_field_value(type_name: Name, field_name: Name, field_type: Type) Term
Generate the encoder for a field’s value.
- hydra.encoding.encode_float_value(float_type: FloatType, val_term: Term) Term
Encode a float value based on its float type.
- hydra.encoding.encode_forall_type(ft: ForallType) Term
Generate an encoder for a polymorphic (forall) type.
- hydra.encoding.encode_injection(type_name: Name, field_name: Name, field_term: Term) Term
Encode an Injection as a term.
- hydra.encoding.encode_integer_value(int_type: IntegerType, val_term: Term) Term
Encode an integer value based on its integer type.
- hydra.encoding.encode_literal_type(v1: LiteralType) Term
Generate an encoder for a literal type.
- hydra.encoding.encode_module(cx: T0, graph: Graph, mod: Module) object
Transform a type module into an encoder module.
- hydra.encoding.encode_module_name(v1: ModuleName) ModuleName
Generate an encoder module name from a source module name.
- hydra.encoding.encode_record_type(rt: Sequence[FieldType]) Term
Generate an encoder for a record type (unnamed — should not be called directly).
- hydra.encoding.encode_record_type_named(ename: Name, rt: Sequence[FieldType]) Term
Generate an encoder for a record type with the given element name.
- hydra.encoding.encode_type_named(ename: Name, typ: Type) Term
Generate an encoder term for a Type, with the element name for nominal types.
- hydra.encoding.encode_union_type(rt: Sequence[FieldType]) Term
Generate an encoder for a union type (placeholder name).
- hydra.encoding.encode_union_type_named(ename: Name, rt: Sequence[FieldType]) Term
Generate an encoder for a union type with the given element name.
- hydra.encoding.encode_wrapped_type(wt: Type) Term
Generate an encoder for a wrapped type (placeholder name).
- hydra.encoding.encode_wrapped_type_named(ename: Name, wt: Type) Term
Generate an encoder for a wrapped type with the given element name.
- hydra.encoding.encoder_collect_forall_variables(typ: Type) Sequence[Name]
Collect forall type variable names from a type.
- hydra.encoding.encoder_collect_ord_vars(typ: Type) Sequence[Name]
Collect type variables needing Ord constraints.
- hydra.encoding.encoder_collect_type_vars_from_type(typ: Type) Sequence[Name]
Collect all type variable names from a type expression.
- hydra.encoding.encoder_full_result_type_named(ename: Name, typ: Type) Type
Get full result type for encoder input, using element name for nominal types.
- hydra.encoding.encoder_type_named(ename: Name, typ: Type) Type
Build encoder function type with element name for nominal types.
- hydra.encoding.encoder_type_scheme(typ: Type) TypeScheme
Construct a TypeScheme for an encoder function from a source type.
- hydra.encoding.encoder_type_scheme_named(ename: Name, typ: Type) TypeScheme
Construct a TypeScheme for an encoder function, with element name for nominal types.
- hydra.encoding.filter_type_bindings(cx: T0, graph: Graph, bindings: Sequence[Binding]) object
Filter bindings to only encodable type definitions.