hydra.validate.core module
Validation functions for core terms and types.
- hydra.validate.core.append_finding(p: ValidationProfile, acc: ValidationResult[T0], finding: object) ValidationResult[T0]
Append a rule-tagged InvalidTermError finding to a ValidationResult, classifying as error or warning per the profile and respecting maxErrors/maxWarnings bounds.
- hydra.validate.core.append_finding_type(p: ValidationProfile, acc: ValidationResult[T0], finding: object) ValidationResult[T0]
Append a rule-tagged InvalidTypeError finding to a ValidationResult, classifying as error or warning per the profile and respecting maxErrors/maxWarnings bounds.
- hydra.validate.core.check_duplicate_bindings(path: SubtermPath, bindings: Sequence[Binding]) object
Check for duplicate binding names in a list of bindings.
- hydra.validate.core.check_duplicate_field_types(fields: Sequence[FieldType], mk_error: Callable[[Name], object]) object
Check for duplicate field names in a list of field types.
- hydra.validate.core.check_duplicate_fields(path: SubtermPath, names: Sequence[Name]) object
Check for duplicate field names in a list of fields.
- hydra.validate.core.check_literal(expected: LiteralType, value: Literal) object
Check that a literal value’s type matches an expected literal type.
- hydra.validate.core.check_shadowing(path: SubtermPath, cx: Graph, names: Sequence[Name]) object
Check if any name in a list shadows a variable already in scope.
- hydra.validate.core.check_term(p: ValidationProfile, typed: bool, path: SubtermPath, cx: Graph, term: Term) object
Check a single term node for validation errors. Rules disabled by the profile are not evaluated.
- hydra.validate.core.check_undefined_type_variables_in_type(path: T0, cx: Graph, typ: Type, mk_error: Callable[[Name], object]) object
Check a type for type variables not bound in the current scope.
- hydra.validate.core.check_undefined_type_variables_in_type_scheme(path: T0, cx: Graph, ts: TypeScheme, mk_error: Callable[[Name], object]) object
Check a type scheme for type variables not bound by the scheme or the current scope.
- hydra.validate.core.enabled(p: ValidationProfile, rule_name: Name) bool
True iff the given rule name appears in the profile’s errorRules or warningRules.
- hydra.validate.core.find_duplicate(names: Sequence[T0]) object
Find the first duplicate name in a list.
- hydra.validate.core.find_duplicate_field_type(names: Sequence[T0]) object
Find the first duplicate name in a list (for field type validation).
- hydra.validate.core.first_error(checks: Sequence[object]) object
Return the first error from a list of optional errors, or nothing if all are valid.
- hydra.validate.core.first_finding(checks: Sequence[object]) object
Return the first rule-tagged finding from a list, or nothing if all are valid.
- hydra.validate.core.first_finding_type(checks: Sequence[object]) object
Return the first rule-tagged type finding from a list, or nothing if all are valid.
- hydra.validate.core.first_type_error(checks: Sequence[object]) object
Return the first type error from a list of optional errors, or nothing if all are valid.
- hydra.validate.core.is_valid_name(name: Name) bool
Check whether a name is valid at an introduction site. Currently rejects empty strings.
- hydra.validate.core.kernel_default_core_profile() ValidationProfile
The default validation profile for term and type validation, with every check classified as an error except InvalidTypeError.singleVariantUnion and InvalidTypeError.emptyRecordType (warnings); maxErrors=1, maxWarnings=20.
- hydra.validate.core.resolve_nominal_type(cx: Graph, tname: Name) object
Resolve a type name to the annotation-stripped type it names in the current graph scope, or Nothing if it does not resolve.
- hydra.validate.core.resolve_record_fields(cx: Graph, tname: Name) object
Resolve a type name to the field list of the record type it names, or Nothing if it does not resolve to a record type.
- hydra.validate.core.resolve_union_fields(cx: Graph, tname: Name) object
Resolve a type name to the field list of the union type it names, or Nothing if it does not resolve to a union type.
- hydra.validate.core.term(p: ValidationProfile, typed: bool, g: Graph, t: Term) ValidationResult[InvalidTermError]
Validate a term against the given ValidationProfile, returning a ValidationResult. Errors hard-stop traversal once maxErrors is reached; warnings are bounded by maxWarnings without causing termination.
- hydra.validate.core.type(p: ValidationProfile, acc: ValidationResult[InvalidTypeError], bound_vars: Set[Name], typ: Type) ValidationResult[InvalidTypeError]
Validate a type against the given ValidationProfile, threading a ValidationResult accumulator through subtypes. Errors hard-stop traversal once maxErrors is reached.
- hydra.validate.core.validate_type_node(p: ValidationProfile, bound_vars: Set[Name], typ: Type) object
Check a single type node for validation errors. Rules disabled by the profile are not evaluated.