hydra.resolution module
Type dereference, lookup, requirements, and instantiation.
- hydra.resolution.dereference_type(cx: T0, graph: Graph, name: Name) object
Dereference a type name to get the actual type (Either version).
- hydra.resolution.f_type_is_polymorphic(typ: Type) bool
Test whether a given System F type is polymorphic (i.e., a forall type).
- hydra.resolution.field_map(fields: Sequence[Field]) Mapping[Name, Term]
Build a map from field name to field term, given a list of fields.
- hydra.resolution.field_type_map(fields: Sequence[FieldType]) Mapping[Name, Type]
Build a map from field name to field type, given a list of field types.
- hydra.resolution.field_types(cx: T0, graph: Graph, t: Type) object
Get field types from a record or union type (Either version).
- hydra.resolution.find_field_type(cx: T0, fname: Name, fields: Sequence[FieldType]) object
Find a field type by name in a list of field types.
- hydra.resolution.fully_strip_and_normalize_type(typ: Type) Type
Fully strip a type of forall quantifiers, normalizing bound variable names for alpha-equivalence comparison.
- hydra.resolution.instantiate_type(cx: InferenceContext, typ: Type) tuple[Type, InferenceContext]
Instantiate a type by replacing all forall-bound type variables with fresh variables, threading InferenceContext.
- hydra.resolution.instantiate_type_scheme(cx: InferenceContext, scheme: TypeScheme) tuple[TypeScheme, InferenceContext]
Instantiate a type scheme with fresh variables, threading InferenceContext.
- hydra.resolution.map_key_resolves_to_string(types: Mapping[Name, Type], key_type: Type) bool
Test whether a map’s key type resolves to string, following aliases and wrappers. Used to decide whether a map may use the compact JSON object encoding.
- hydra.resolution.nominal_application(tname: Name, args: Sequence[Type]) Type
Apply type arguments to a nominal type.
- hydra.resolution.require_record_type(cx: T0, graph: Graph, name: Name) object
Require a name to resolve to a record type.
- hydra.resolution.require_row_type(cx: T0, label: str, getter: Callable[[Type], object], graph: Graph, name: Name) object
Require a name to resolve to a row type.
- hydra.resolution.require_schema_type(cx: InferenceContext, types: Mapping[Name, TypeScheme], tname: Name) object
Look up a schema type and instantiate it, threading InferenceContext.
- hydra.resolution.require_union_field(cx: T0, graph: Graph, tname: Name, fname: Name) object
Require a field type from a union type.
- hydra.resolution.require_union_type(cx: T0, graph: Graph, name: Name) object
Require a name to resolve to a union type.
- hydra.resolution.resolve_base_type(types: Mapping[Name, Type], typ: Type) Type
Resolve a type to its base, following annotations, type aliases (Type.variable dereferenced against the given type map), and Type.wrap bodies, transitively. An unresolvable variable name (not found in the map) is returned as-is, since the caller is in the best position to decide whether that is an error. As with hydra.sources.kernel.terms.lexical.dereferenceSchemaType, this assumes type aliases form an acyclic reference graph, as guaranteed by schema construction; a genuinely self-referential alias is not a supported input and would not terminate.
- hydra.resolution.resolve_type(graph: Graph, typ: Type) object
Resolve a type, dereferencing type variables.
- hydra.resolution.type_to_type_scheme(t0: Type) TypeScheme
Convert a (System F -style) type to a type scheme.