Class DataType

All Implemented Interfaces:
NamedType, Type

public class DataType extends ParameterizedType
Algebraic type.
  • Field Details

  • Constructor Details

    • DataType

      DataType(String name, String moniker, List<? extends Type> arguments, SortedMap<String,Type.Key> typeConstructors)
      Creates a DataType.

      Called only from TypeSystem.dataTypes(List).

      If the typeSystem argument is specified, canonizes the types inside type-constructors. This also allows temporary types (necessary while creating self-referential data types) to be replaced with real DataType instances.

      During replacement, if a type matches placeholderType it is replaced with this. This allows cyclic graphs to be copied.

    • DataType

      protected DataType(Op op, String name, String moniker, List<? extends Type> arguments, SortedMap<String,Type.Key> typeConstructors)
      Called only from DataType constructor.
  • Method Details

    • key

      public Type.Key key()
      Description copied from interface: Type
      Description of the type, e.g. "int", "int -> int", "NONE | SOME of 'a".
    • accept

      public <R> R accept(TypeVisitor<R> typeVisitor)
    • typeConstructors

      public SortedMap<String,Type> typeConstructors(TypeSystem typeSystem)
    • copy

      public DataType copy(TypeSystem typeSystem, UnaryOperator<Type> transform)
      Description copied from interface: Type
      Copies this type, applying a given transform to component types, and returning the original type if the component types are unchanged.
    • describe

      public StringBuilder describe(StringBuilder buf)
      Writes out the definition of the datatype. For example,
      datatype ('a,'b) tree = Empty | Node of ('a,'b) tree * 'b * 'a * ('a,'b) tree