Type#

class Type(*args, **kwargs)[source]#

Abstract base class for types.

A type is an expression representing a structured collection of values.

It can be either a TypeVariable or a TypeApplication.

Type variable#

class TypeVariable(arg1, **kwargs)[source]#

Type variable.

A type variable is an expression representing an arbitrary type.

Parameters:
  • arg1 – Id.

  • kwargs – Annotations.

Returns:

A new TypeVariable.

Example:#
a = TypeVariable('a')
print(a)
# a : *

See also

TypeVariables().

Type application#

class TypeApplication(arg1, *args, **kwargs)[source]#

Type application.

A type application is an expression representing the type obtained by the application of a type constructor to other types.

Parameters:
Returns:

A new TypeApplication.

Example:#
c0 = TypeConstructor('c0', 0)
print(c0())              # Equivalent to: TypeApplication(c0)
# c0 : *

c1 = TypeConstructor('c1', 1)
print(c1(c0()))          # Equivalent to: TypeApplication(c1, c0())
# c1 c0 : *