internal static RigidTypeException Create(string name, Type type) { var sb = new StringBuilder(); var tpp = new TypePrettyPrinter(); type.PrettyPrint(tpp, sb, 0); return(new RigidTypeException(name, sb.ToString(), tpp)); }
internal static OccursCheckException Create(Type lhs, Type rhs) { var sb1 = new StringBuilder(); var sb2 = new StringBuilder(); var tpp = new TypePrettyPrinter(); lhs.PrettyPrint(tpp, sb1, 0); rhs.PrettyPrint(tpp, sb2, 0); return(new OccursCheckException(sb1.ToString(), sb2.ToString(), tpp)); }
public override void PrettyPrint(TypePrettyPrinter typePrettyPrinter, StringBuilder stringBuilder, int level) { stringBuilder.Append("forall"); foreach (var variable in Arguments) { stringBuilder.Append(" " + typePrettyPrinter[variable]); } stringBuilder.Append(". "); Inner.PrettyPrint(typePrettyPrinter, stringBuilder, 1); }
public override void PrettyPrint(TypePrettyPrinter typePrettyPrinter, StringBuilder stringBuilder, int level) { if (level > 2) { stringBuilder.Append('('); } Argument.PrettyPrint(typePrettyPrinter, stringBuilder, 3); stringBuilder.Append(" -> "); Result.PrettyPrint(typePrettyPrinter, stringBuilder, 2); if (level > 2) { stringBuilder.Append(')'); } }
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; } }