hydra.extract.core module

Extraction and validation for hydra.core types.

hydra.extract.core.bigint(graph: Graph, t: Term) object

Extract an arbitrary-precision integer value from a term.

hydra.extract.core.bigint_value(v: IntegerValue) object

Extract a bigint value from an IntegerValue.

hydra.extract.core.binary(graph: Graph, t: Term) object

Extract a binary data value from a term.

hydra.extract.core.binary_literal(v: Literal) object

Extract a binary literal from a Literal value.

hydra.extract.core.boolean(graph: Graph, t: Term) object

Extract a boolean value from a term.

hydra.extract.core.boolean_literal(v: Literal) object

Extract a boolean literal from a Literal value.

hydra.extract.core.cases(name: Name, graph: Graph, term0: Term) object

Extract case statement from a term.

hydra.extract.core.decimal(graph: Graph, t: Term) object

Extract an arbitrary-precision decimal value from a term.

hydra.extract.core.decimal_literal(v: Literal) object

Extract a decimal literal from a Literal value.

hydra.extract.core.decode_either(left_decoder: Callable[[Graph, Term], object], right_decoder: Callable[[Graph, Term], object], g: Graph, term: Term) object

Decode an Either value using the provided left and right decoders.

hydra.extract.core.decode_list(elem_decoder: Callable[[Graph, Term], object], g: Graph, term: Term) object

Decode a list of elements using the provided element decoder.

hydra.extract.core.decode_map(key_decoder: Callable[[Graph, Term], object], val_decoder: Callable[[Graph, Term], object], g: Graph, term: Term) object

Decode a Map using the provided key and value decoders.

hydra.extract.core.decode_maybe(elem_decoder: Callable[[Graph, Term], object], g: Graph, term: Term) object

Decode a Maybe value using the provided element decoder.

hydra.extract.core.decode_pair(first_decoder: Callable[[Graph, Term], object], second_decoder: Callable[[Graph, Term], object], g: Graph, term: Term) object

Decode a Pair using the provided first and second decoders.

hydra.extract.core.decode_set(elem_decoder: Callable[[Graph, Term], object], g: Graph, term: Term) object

Decode a Set using the provided element decoder.

hydra.extract.core.decode_unit(g: Graph, term: Term) object

Decode a unit value.

hydra.extract.core.either_term(left_fun: Callable[[Term], object], right_fun: Callable[[Term], object], graph: Graph, term0: Term) object

Extract an either value from a term, applying functions to the left and right values.

hydra.extract.core.either_type(typ: Type) object

Extract the left and right types from an either type.

hydra.extract.core.field(fname: Name, mapping: Callable[[Term], object], graph: Graph, fields: Sequence[Field]) object

Extract a field value from a list of fields.

hydra.extract.core.float32(graph: Graph, t: Term) object

Extract a 32-bit floating-point value from a term.

hydra.extract.core.float32_value(v: FloatValue) object

Extract a float32 value from a FloatValue.

hydra.extract.core.float64(graph: Graph, t: Term) object

Extract a 64-bit floating-point value from a term.

hydra.extract.core.float64_value(v: FloatValue) object

Extract a float64 value from a FloatValue.

hydra.extract.core.float_literal(lit: Literal) object

Extract a floating-point literal from a Literal value.

hydra.extract.core.float_value(graph: Graph, t: Term) object

Extract a float value from a term.

hydra.extract.core.function_type(typ: Type) object

Extract a function type from a type.

hydra.extract.core.injection(expected: Name, graph: Graph, term0: Term) object

Extract a field from a union term.

hydra.extract.core.int16(graph: Graph, t: Term) object

Extract a 16-bit signed integer value from a term.

hydra.extract.core.int16_value(v: IntegerValue) object

Extract an int16 value from an IntegerValue.

hydra.extract.core.int32(graph: Graph, t: Term) object

Extract a 32-bit signed integer value from a term.

hydra.extract.core.int32_value(v: IntegerValue) object

Extract an int32 value from an IntegerValue.

hydra.extract.core.int64(graph: Graph, t: Term) object

Extract a 64-bit signed integer value from a term.

hydra.extract.core.int64_value(v: IntegerValue) object

Extract an int64 value from an IntegerValue.

hydra.extract.core.int8(graph: Graph, t: Term) object

Extract an 8-bit signed integer value from a term.

hydra.extract.core.int8_value(v: IntegerValue) object

Extract an int8 value from an IntegerValue.

hydra.extract.core.integer_literal(lit: Literal) object

Extract an integer literal from a Literal value.

hydra.extract.core.integer_value(graph: Graph, t: Term) object

Extract an integer value from a term.

hydra.extract.core.lambda_(graph: Graph, term0: Term) object

Extract a lambda from a term.

hydra.extract.core.lambda_body(graph: Graph, term: Term) object

Extract the body of a lambda term.

hydra.extract.core.let(graph: Graph, term0: Term) object

Extract a let expression from a term.

hydra.extract.core.let_binding(n: str, graph: Graph, term: Term) object

Extract a binding with the given name from a let term.

hydra.extract.core.list(graph: Graph, term: Term) object

Extract a list of terms from a term.

hydra.extract.core.list_of(f: Callable[[Term], object], graph: Graph, term: Term) object

Extract a list of values from a term, mapping a function over each element.

hydra.extract.core.list_type(typ: Type) object

Extract the element type from a list type.

hydra.extract.core.literal(graph: Graph, term0: Term) object

Extract a literal value from a term.

hydra.extract.core.map(fk: Callable[[Term], object], fv: Callable[[Term], object], graph: Graph, term0: Term) object

Extract a map of key-value pairs from a term, mapping functions over each key and value.

hydra.extract.core.map_type(typ: Type) object

Extract the key and value types from a map type.

hydra.extract.core.n_args(name: Name, n: int, args: Sequence[T0]) object

Ensure a function has the expected number of arguments.

hydra.extract.core.optional_term(f: Callable[[Term], object], graph: Graph, term0: Term) object

Extract an optional value from a term, applying a function to the value if present.

hydra.extract.core.optional_type(typ: Type) object

Extract the base type from an optional type.

hydra.extract.core.pair(kf: Callable[[Term], object], vf: Callable[[Term], object], graph: Graph, term0: Term) object

Extract a pair of values from a term, applying functions to each component.

hydra.extract.core.record(expected: Name, graph: Graph, term0: Term) object

Extract a record’s fields from a term.

hydra.extract.core.record_type(ename: T0, typ: Type) object

Extract the field types from a record type.

hydra.extract.core.require_field(field_name: str, decoder: Callable[[T0, T1], object], field_map: Mapping[Name, T1], g: T0) object

Require a field from a record’s field map and decode it.

hydra.extract.core.set(graph: Graph, term: Term) object

Extract a set of terms from a term.

hydra.extract.core.set_of(f: Callable[[Term], object], graph: Graph, term: Term) object

Extract a set of values from a term, mapping a function over each element.

hydra.extract.core.set_type(typ: Type) object

Extract the element type from a set type.

hydra.extract.core.string(graph: Graph, t: Term) object

Extract a string value from a term.

hydra.extract.core.string_literal(v: Literal) object

Extract a string literal from a Literal value.

hydra.extract.core.strip_with_decoding_error(g: Graph, term: Term) object

Strip annotations and dereference variables, returning Either DecodingError Term.

hydra.extract.core.term_record(graph: Graph, term0: Term) object

Extract a record from a term.

hydra.extract.core.to_field_map(record: Record) Mapping[Name, Term]

Convert a Record’s fields to a Map from Name to Term.

hydra.extract.core.uint16(graph: Graph, t: Term) object

Extract a 16-bit unsigned integer value from a term.

hydra.extract.core.uint16_value(v: IntegerValue) object

Extract a uint16 value from an IntegerValue.

hydra.extract.core.uint32(graph: Graph, t: Term) object

Extract a 32-bit unsigned integer value from a term.

hydra.extract.core.uint32_value(v: IntegerValue) object

Extract a uint32 value from an IntegerValue.

hydra.extract.core.uint64(graph: Graph, t: Term) object

Extract a 64-bit unsigned integer value from a term.

hydra.extract.core.uint64_value(v: IntegerValue) object

Extract a uint64 value from an IntegerValue.

hydra.extract.core.uint8(graph: Graph, t: Term) object

Extract an 8-bit unsigned integer value from a term.

hydra.extract.core.uint8_value(v: IntegerValue) object

Extract a uint8 value from an IntegerValue.

hydra.extract.core.union_type(ename: T0, typ: Type) object

Extract the field types from a union type.

hydra.extract.core.unit(term: Term) object

Extract a unit value from a term.

hydra.extract.core.unit_variant(tname: Name, graph: Graph, term: Term) object

Extract a unit variant (a variant with an empty record value) from a union term.

hydra.extract.core.wrap(expected: Name, graph: Graph, term0: Term) object

Extract the wrapped value from a wrapped term.

hydra.extract.core.wrapped_type(ename: T0, typ: Type) object

Extract the wrapped type from a wrapper type.