public override Type Instantiate() { var subst = new Substitution(); foreach (var arg in Arguments.Where(arg => arg.RigidName == null)) { subst.Bind(arg, new TypeVariable()); } return(Inner.Perform(subst)); }
public void Unify(Type that, Substitution substitution) { try { Perform(substitution).SubstUnify(that.Perform(substitution), substitution); } catch (StackedException ex) { var sb = new StringBuilder("While trying to unify "); PrettyPrint(ex.PrettyPrinter, sb, 0); sb.Append(" with "); that.PrettyPrint(ex.PrettyPrinter, sb, 0); ex.Push(sb.ToString()); throw; } }
public override void DoUnify(Type var, Substitution substitution) { if (this == var) { return; } if (RigidName != null) { var.UnifyWithRigid(this, substitution); } else { if (var.FreeVariables().Contains(this)) { throw OccursCheckException.Create(var.Perform(substitution), this.Perform(substitution)); } substitution.Bind(this, var); } }
public override Type Perform(Substitution substitution) { return(new FunctionType(Argument.Perform(substitution), Result.Perform(substitution))); }
public virtual void DoUnify(Type that, Substitution substitution) { throw TypeException.Create(Perform(substitution), that.Perform(substitution)); }