public static QualifiedType Infer(InferenceState initial, ITerm term) { var inference = new TypeInference(initial).Infer(term, out var result); Console.WriteLine($"Final: {inference}"); var normalized = inference._state.Context.Normalize().Apply(result); if (normalized.Context.FreeVariables().Except(normalized.Head.FreeVariables()).Any()) { throw new Exception($"Ambiguity detected in '{normalized}'"); } return(new QualifiedType(normalized.Context.Reduce(inference._state.Context), normalized.Head)); }
private TypeInference(InferenceState inference) { this._state = inference; }
private TypeInference(FreshVariableStream fresh, IImmutableList <IContextEntry> context) { this._state = new InferenceState(fresh, context); }
private TypeInference() { this._state = new InferenceState(new FreshVariableStream(), ImmutableList <IContextEntry> .Empty); }