package code.type.visitor;

import code.type.*;

/**
 * ToStringTypeVisitor
 *
 * Create a string representation of the type
 *
 * @author David Shapiro
 * @since August 19, 2005
 */

  public class ToStringTypeVisitor
	        implements TypeVisitor<String,Object>
  {
    public String visit(TypeConstructor t, Object ignore)
    { return t.name; }

    public String visit(TypeVariable t, Object ignore)
    { return t.name; }

    public String visit(FunctionType t, Object ignore)
    {
      return "->(" + t.domain.accept(this, null) + ", " + t.range.accept(this, null) + ")";
    }

    public String visit(TypeConstructorApplication t, Object ignore)
    {
      String retval = "[" + t.typeConstructor + ":";
      for (TypeExpression arg : t.arguments)
        retval += arg.accept(this, null) + ",";
      retval += "] ";
      return retval;
    }
  }


