hydra.variables module
Free variable analysis, term-level substitution, and unshadowing.
- hydra.variables.free_type_variables_in_term(term0: Term) Set[Name]
Get the set of free type variables in a term (including schema names, where they appear in type annotations). In this context, only the type schemes of let bindings can bind type variables; type lambdas do not.
- hydra.variables.free_variables_in_term(term: Term) Set[Name]
Find the free variables (i.e. variables not bound by a lambda or let) in a term.
- hydra.variables.free_variables_in_type(typ: Type) Set[Name]
Find the free variables (i.e. variables not bound by a lambda or let) in a type.
- hydra.variables.free_variables_in_type_ordered(typ: Type) Sequence[Name]
Find the free variables in a type in deterministic left-to-right order.
- hydra.variables.free_variables_in_type_scheme(ts: TypeScheme) Set[Name]
Find free variables in a type scheme.
- hydra.variables.free_variables_in_type_scheme_simple(ts: TypeScheme) Set[Name]
Find free variables in a type scheme (simple version).
- hydra.variables.free_variables_in_type_simple(typ: Type) Set[Name]
Same as freeVariablesInType, but ignores the binding action of lambda types.
- hydra.variables.is_free_variable_in_term(v: Name, term: Term) bool
Check whether a variable is free (not bound) in a term.
- hydra.variables.normalize_type_variables_in_term(term: Term) Term
Recursively replace the type variables of let bindings with the systematic type variables t0, t1, t2, …
- hydra.variables.replace_free_term_variable(vold: Name, tnew: Term, term: Term) Term
Replace a free variable in a term.
- hydra.variables.replace_free_type_variable(v: Name, rep: Type, typ: Type) Type
Replace free occurrences of a name in a type.
- hydra.variables.substitute_type_variables(subst: Mapping[Name, Name], typ: Type) Type
Substitute type variables in a type.
- hydra.variables.substitute_variable(from_: Name, to: Name, term: Term) Term
Substitute one variable for another in a term.