Skip to content
sw17ch edited this page Mar 23, 2012 · 6 revisions

Type Syntax

Types are defined as one of the following:

  • TypeName
  • TypeVariable
  • ParameterizedType
  • FunctionType

Type Names

Pattern: [A-Z][A-Za-z0-9_]*

Examples:

  • UInt32
  • Foo
  • FlabbaJabbaJangalang

Type Variables

Pattern: [a-z_][A-Za-z0-9_]*

Examples:

  • foo
  • a
  • _zoop
  • darthVadar86
  • (parensOptional)

Parameterized Types

Parameterized types are a Type Name or a Type Variable followed by any number of Type Names, Type Variables, or Function Types.

Pattern: [TypeName | TypeVariable][TypeName | TypeVariable | FunctionType]+

Examples:

  • Foo a
  • Foo Int a
  • Flippity Floppity (a -> flooby)
  • a Int (Foo a)
  • (Parens optional)

Function Types

Function types are any number of parameters, an arrow (->), and a return type.

Pattern: ([AnyType](,[AnyType]*)){0,1}->[AnyType]{0,1}

Examples:

  • ->
  • a -> b
  • Int, a -> Bar
  • (a -> b) -> b
  • -> Int
  • Int ->
  • Foo a, Bar b, Baz (Foo a) -> Int

Clone this wiki locally