Skip to content

Types DSL

Nikolaos Dymitriadis edited this page Mar 29, 2020 · 1 revision

Constructing complex types

There are two basic ways to create complex types by composing simpler ones. First, some types have type parameters that indicate an of type relationship, eg. list(int(+)) meaning a list of integers. Second, some types can be nested, resulting in their operations being composed, which corresponds to a within type relationship, eg. list / list(int(+)) meaning a list-within-a-list of integers.

The distinction between these two types of composition makes it possible to precisely specify how deep an operation should be: a map over list(list(int(+))) will map over lists within the outer list, while a map over list / list(int(+)) will map over the integers within the inner lists.

List of Types

Id

id(InnerType)

Identity functor, which behaves exactly as the inner type for operations that are available for it, but which also adds some other operations, most notably map.

List

list(ContentType)

Tuple

(Type1, ..., TypeN)

Functor

functor(Symbol, Arity, Fields)

Type of functors (complex terms) of given Symbol and Arity (which can be variables). Fields can be of any of the following forms:

  • FieldNumber - indicates a single field that the functor can be mapped on, starting at 1
  • FieldNumber / FieldType - indicates a single field that should be treated as a nested (categorical) functor of type Fieldtype
  • [FieldNumber] and [FieldNumber / FieldType] - (typed) multi-field variant that allows mapping multiple fields (possibly as nested functors)
Clone this wiki locally