Type Members

A type member is a member that defines an identified type. It can be thought of as the assertion that an identifier represents a type that is a subtype of another type. It simply inserts this new identified subtype in the identified type hierarchy.


A type member can be thought of as a java interface or a go interface in that a type member defines an identifier that may be used to refer to a certain type in the identified type hierarchy.

It is represented by an identifier, a type relationship token, and a type. For instance, the following snippet:

MyType =: Any

represents the definition of the identified type MyType as a subtype of the identified type Any.


The type defined by a type member can also be structural:

U =: [x: '']

Here, U is a subtype of [x: ''], and also [x: ''] is a subtype of U (since U declares all of the members of [x: '']). This does not mean every occurence of U can be lexically replaced with [x: '']. For instance, in the following snippet:

A =: [x: '']
B =: A

a: A = {x = 'value'}
b: B = a

The evaluation of b abruptly halts the execution of the interpreter with the following informative message (accordingly to type-checking):

error: type mismatch:
expected: B
actual: A
at <row>:<col>:
    b: B = a

To summarize: [x: ''] being a subtype of A – while B is also a subtype of A – means in no circumstances that A is a subtype of B.