public virtual void SubstUnify(Type that, Substitution substitution) { if (this != that) { that.DoUnify(this, substitution); } }
public override void SubstUnify(Type that, Substitution substitution) { if (that != this) { that.DoUnify(this, substitution); } }
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 override Type Perform(Substitution substitution) { var local = substitution.Local(); foreach (var arg in Arguments) { local.Map = local.Map.Remove(arg); } return(new TypeScheme(Arguments, Inner.Perform(local))); }
public override void DoUnify(TupleType var, Substitution substitution) { if (Arguments.Count != var.Arguments.Count) { throw TypeException.Create(this.Perform(substitution), var.Perform(substitution)); } for (var i = 0; i < Arguments.Count; ++i) { Arguments[i].Perform(substitution).Unify(var.Arguments[i].Perform(substitution), substitution); } }
public override void UnifyWithRigid(TypeVariable var, Substitution substitution) { if (var == this) { return; } if (RigidName != null) { throw RigidTypeException.Create(RigidName, var); } substitution.Bind(this, var); }
public override Type Perform(Substitution substitution) { if (!substitution.Map.ContainsKey(this)) { return(this); } if (RigidName != null) { throw RigidTypeException.Create(RigidName, substitution.Map[this]); } return(substitution.Map[this].Perform(substitution)); }
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 void DoUnify(FunctionType var, Substitution substitution) { Argument.Perform(substitution).Unify(var.Argument.Perform(substitution), substitution); Result.Perform(substitution).Unify(var.Result.Perform(substitution), substitution); }
public override Type Perform(Substitution substitution) { return(new FunctionType(Argument.Perform(substitution), Result.Perform(substitution))); }
public override void DoUnify(FloatingType var, Substitution substitution) { }
public override void DoUnify(CharacterType var, Substitution substitution) { }
public virtual void DoUnify(TupleType var, Substitution substitution) { DoUnify((Type)var, substitution); }
public virtual void DoUnify(TypeVariable var, Substitution substitution) { var.DoUnify(this, substitution); }
public override Type Perform(Substitution substitution) { return(new TupleType(Arguments.Select(x => x.Perform(substitution)).ToList())); }
public virtual void DoUnify(FunctionType var, Substitution substitution) { DoUnify((Type)var, substitution); }
public virtual void DoUnify(FloatingType var, Substitution substitution) { DoUnify((Type)var, substitution); }
public virtual void DoUnify(CharacterType var, Substitution substitution) { DoUnify((Type)var, substitution); }
public virtual void DoUnify(IntegralType var, Substitution substitution) { DoUnify((Type)var, substitution); }
public override Type Perform(Substitution substitution) { return(this); }
public override void DoUnify(IntegralType var, Substitution substitution) { }
public virtual void DoUnify(Type that, Substitution substitution) { throw TypeException.Create(Perform(substitution), that.Perform(substitution)); }
public abstract Type Perform(Substitution substitution);
public virtual void UnifyWithRigid(TypeVariable var, Substitution subst) { throw RigidTypeException.Create(var.RigidName, this); }