SubstitutionMap
struct SubstitutionMap : Sendable
extension SubstitutionMap: CustomStringConvertible
A substitution table mapping type and term variables to assumptions during inference.
-
A policy for substituting variables during reification.
See moreDeclaration
Swift
enum SubstitutionPolicy : Sendable -
A map from type variable to its assignment.
Declaration
Swift
private(set) var types: [TypeVariable : AnyType] { get } -
A map from term variable to its assignment.
Declaration
Swift
private(set) var terms: [TermVariable : AnyTerm] { get } -
Creates an empty substitution map.
Declaration
Swift
init() -
Creates an instance with the given properties.
Declaration
Swift
private init(types: [TypeVariable : AnyType], terms: [TermVariable : AnyTerm]) -
Returns a copy of this instance with its internal representation optimized.
Declaration
Swift
func optimized() -> SubstitutionMap -
Returns the substitution for
v, if any.Declaration
Swift
subscript(v: TypeVariable) -> AnyType? { get } -
Returns the substitution of
tin this map ortis no such substitution exists. -
Returns the substitution for
v, if any.Declaration
Swift
subscript(v: TermVariable) -> AnyTerm? { get } -
Returns the substitution of
tin this map ortis no such substitution exists. -
Assigns
substitutiontovariable.Declaration
Swift
mutating func assign(_ substitution: AnyType, to variable: TypeVariable) -
Assigns
substitutiontovariable.Declaration
Swift
mutating func assign(_ substitution: AnyTerm, to variable: TermVariable) -
Returns the type variable representing the equivalence class of
vinself.Declaration
Swift
private func walk(_ v: TypeVariable) -> TypeVariable -
Returns the term variable representing the equivalence class of
vinself.Declaration
Swift
private func walk(_ v: TermVariable) -> TermVariable -
Returns
trueif any variable in the equivalence class ofvoccurs nested int.Declaration
Swift
private func occurCheck(_ v: TypeVariable, _ t: AnyType) -> Bool -
Returns a copy of
typewhere each variable is replaced by its substitution inselfor the application ofsubstitutionPolicyis no such substitution exists.The default substitution policy is
substituteByErrorbecause we typically usereifyafter having built a complete solution and therefore don’t expect its result to still contain open type variables.Declaration
Swift
func reify( _ type: AnyType, withVariables substitutionPolicy: SubstitutionPolicy = .substitutedByError ) -> AnyType -
Returns a copy of
termwhere each variable is replaced by its substitution inselfor the application ofsubstitutionPolicyis no such substitution exists.Declaration
Swift
func reify( _ term: AnyTerm, withVariables substitutionPolicy: SubstitutionPolicy ) -> AnyTerm -
Returns a copy of
rwhere each generic argument is replaced by the result of applyingreify(withVariables:)on it.Declaration
Swift
func reify( reference r: DeclReference, withVariables substitutionPolicy: SubstitutionPolicy ) -> DeclReference -
Returns a copy of
awhere each variable is replaced by its substitution value inselfor the applicationsubstitutionPolicyis no such substitution exists.Declaration
Swift
private func reify( argument a: GenericArguments, withVariables substitutionPolicy: SubstitutionPolicy ) -> GenericArguments -
Returns a copy of
vwhere each variable is replaced by its substitution value inselfor the applicationsubstitutionPolicyis no such substitution exists.Declaration
Swift
private func reify( value v: CompileTimeValue, withVariables substitutionPolicy: SubstitutionPolicy ) -> CompileTimeValue -
Removes the key/value pairs in
selfthat are not also inother.Declaration
Swift
mutating func formIntersection(_ other: `Self`) -
Returns a new substitution map containing the key/value pairs common to
selfandother.Declaration
Swift
func intersection(_ other: `Self`) -> SubstitutionMap -
Declaration
Swift
var description: String { get }
View on GitHub