Type System

The type system defines every type the Viper runtime understands. Type is the base class: it exposes the primitive types as static accessors (Type.INT64, Type.STRING, …) and serves as the common supertype of the parameterized container, algebraic, and user-defined types.

When to use: reach for types to describe schemas, to validate data, and to build parameterized containers such as vectors and maps before instantiating values against them.

Quick Start

const { Type, TypeVector, TypeMap, TypeOptional } = require('@digitalsubstrate/dsviper');

// Primitive types are static accessors on Type
const tInt = Type.INT64;
const tStr = Type.STRING;
tStr.representation();                        // "string"

// Parameterized container types — construct with `new`
const tVec = new TypeVector(Type.STRING);    // vector<string>
const tMap = new TypeMap(Type.STRING, Type.INT64);
tMap.representation();                        // "map<string, int64>"

// Nested types compose freely
const tNested = new TypeMap(Type.STRING, new TypeVector(Type.FLOAT));

// Nullable type
const tOpt = new TypeOptional(Type.STRING);
tOpt.representation();                        // "optional<string>"

A type is the schema half of the runtime; pair it with Value.create(type, native) to mint an instance (see Values):

const { Value, Type } = require('@digitalsubstrate/dsviper');

const v = Value.create(Type.STRING, 'hi');   // a ValueString
v.encoded();                                  // "hi"

Choosing the Right Type

Use Case

Type Class

Example

Primitive value

Type.STRING, Type.INT64

static accessors

Homogeneous list

TypeVector

new TypeVector(Type.INT64)

Key-value mapping

TypeMap

new TypeMap(Type.STRING, Type.INT64)

Nullable value

TypeOptional

new TypeOptional(Type.STRING)

Concurrent list

TypeXArray

new TypeXArray(Type.STRING)

Fixed-size tuple

TypeTuple

new TypeTuple([Type.INT64, Type.STRING])

The mirror of this page for the Python binding is Type System; for a narrative walkthrough of types and values together, see Types and Values.

Generated from the @digitalsubstrate/dsviper TypeScript declarations (index.d.ts) by TypeDoc.

Base Class

Class

Description

Type

The primitive types, and the utilities that act on any type

TypeName

Describes the name of a type: its namespace and its identifier

Primitive Types

Class

Description

TypeVoid

The void type

TypeBool

The bool type

TypeUInt8

The uint8 type

TypeUInt16

The uint16 type

TypeUInt32

The uint32 type

TypeUInt64

The uint64 type

TypeInt8

The int8 type

TypeInt16

The int16 type

TypeInt32

The int32 type

TypeInt64

The int64 type

TypeFloat

The float type

TypeDouble

The double type

TypeString

The string type

TypeBlob

The blob type

TypeBlobId

The blob_id type

TypeCommitId

The commit_id type

TypeUUId

The uuid type

Container Types

Class

Description

TypeVector

The vector type

TypeSet

The set type

TypeMap

The map<keyType, elementType> type

TypeXArray

The xarray type

TypeOptional

The optional type

Algebraic Types

Class

Description

TypeTuple

The tuple<T0, …> type

TypeVec

The vec<numericType, size> type

TypeMat

The mat<numericType, columns, rows> type

TypeVariant

The variant<T0, …> type

TypeAny

The any type

User-Defined Types

Class

Description

TypeStructure

A struct type

TypeStructureDescriptor

Describes the fields a struct will be created with

TypeStructureField

One field of a struct type, as TypeStructure.fields(), query() and check() answer it

TypeEnumeration

An enum type

TypeEnumerationCase

One case of an enum type, as TypeEnumeration.cases(), query() and check() answer it

TypeEnumerationDescriptor

Describes the cases an enum will be created with

Concept Types

Class

Description

TypeConcept

A concept type: a kind of thing the model names, whose instances keys address and attachments file documents under

TypeClub

A club type: a named list of concepts, so that one key type can address an instance of any of them

TypeKey

The key type

TypeAnyConcept

The any_concept type

Reference

class Type()

The primitive types, and the utilities that act on any type.

Type.INT64, Type.STRING and the other scalars are read from here; the parameterized types are their own classes. Also encodes, decodes and sizes a type, and hashes it.

Note: Not directly instantiable.

exported from index.d

Type.ANY

type: readonly TypeAny

Type.ANY_CONCEPT

type: readonly TypeAnyConcept

Type.BLOB

type: readonly TypeBlob

Type.BLOB_ID

type: readonly TypeBlobId

Type.BOOL

type: readonly TypeBool

Type.COMMIT_ID

type: readonly TypeCommitId

Type.DOUBLE

type: readonly TypeDouble

Type.FLOAT

type: readonly TypeFloat

Type.INT16

type: readonly TypeInt16

Type.INT32

type: readonly TypeInt32

Type.INT64

type: readonly TypeInt64

Type.INT8

type: readonly TypeInt8

Type.STRING

type: readonly TypeString

Type.UINT16

type: readonly TypeUInt16

Type.UINT32

type: readonly TypeUInt32

Type.UINT64

type: readonly TypeUInt64

Type.UINT8

type: readonly TypeUInt8

Type.UUID

type: readonly TypeUUId

Type.VOID

type: readonly TypeVoid

Type.compare(other)
Arguments:
  • other (Type)

Returns:

number

Type.description(namespace)
Return the same as representation(), with three exceptions: a struct spells out

its fields in braces, each as name:type with its default when it has one, then its name; an enum spells out its cases in braces as .name, then its name; and a variant writes variant<T0, T1, …> where representation() gives the bare T0|T1|…. namespace qualifies the names.

Arguments:
  • namespace (NameSpace | null)

Returns:

string

Type.equals(other)
Arguments:
  • other (unknown)

Returns:

boolean

Type.representation(namespace)
Return the type written out: the built-in name for a primitive, the declared name for

a named type, the parameterised form for a container - vector<element>, map<key, element>, vec<element, size> - and T0|T1|… for a variant. namespace qualifies the names; the global namespace is used when it is undefined.

Arguments:
  • namespace (NameSpace | null)

Returns:

string

Type.runtimeId()

Return the uuid identifying this type.

It is computed from what the type is, so the same declaration yields the same id in any Definitions. Definitions says what each kind is computed from.

Returns:

ValueUUId

Type.toString()
Returns:

string

Type.typeCode()
Return the code naming this kind of type, such as “int32”, “struct” or

“vector”.

Returns:

string

static Type.decode(blob, definitions, streamCodecInstancing)
Return a type by decoding the blob with Codec.STREAM_BINARY if not

specified.

Arguments:
  • blob (ValueBlob)

  • definitions (DefinitionsConst)

  • streamCodecInstancing (StreamCodecInstancing | null)

Returns:

Type

static Type.encode(type, streamCodecInstancing)
Return a blob that encodes the type with Codec.STREAM_BINARY if not

specified.

Arguments:
  • type (Type)

  • streamCodecInstancing (StreamCodecInstancing | null)

Returns:

ValueBlob

static Type.hexdigest(type, hashing)
Return the hexa digest of the type computed with the hashing interface

if specified else use SHA1.

Arguments:
  • type (Type)

  • hashing (Hashing | null)

Returns:

string

static Type.isSized(type)

Return true if the type has a fixed size and reads back alone.

A key is two uuids yet not sized: reading one back needs the definitions, which a pack-sized vector does not hold.

Arguments:
  • type (Type)

Returns:

boolean

static Type.read(streamReading, definitions)

Read and return a type.

Arguments:
  • streamReading (StreamReading)

  • definitions (DefinitionsConst)

Returns:

Type

static Type.sizeOf(type, streamSizing)

Return the fixed size of the type or throw.

Arguments:
  • type (Type)

  • streamSizing (StreamSizing)

Returns:

number

static Type.useBlobId(type)

Return true if the type uses the type blob_id.

Arguments:
  • type (Type)

Returns:

boolean

static Type.useCommitId(type)

Return true if the type uses the type commit_id.

Arguments:
  • type (Type)

Returns:

boolean

static Type.write(type, streamWriting)

Write a type.

Arguments:
  • type (Type)

  • streamWriting (StreamWriting)

class TypeName(nameSpace, name)

Describes the name of a type: its namespace and its identifier.

Build one to look a registered type up by name - that is what DefinitionsInspector.checkStructure, checkConcept, checkClub and checkEnumeration take. An attachment is not a type but binds a key type to one, so checkAttachment takes its identifier instead. Pass NameSpace.GLOBAL for a type of the global namespace.

The name is an identifier: a letter, then letters, digits and underscores; another throws TypeError.

Two are equal when their namespaces’ uuids and their names are.

exported from index.d

Build a name to look a registered type up by - what DefinitionsInspector’s

checkStructure, checkConcept, checkClub and checkEnumeration take. An attachment is not a type but binds a key type to one, so checkAttachment takes its identifier instead. NameSpace.GLOBAL for the global namespace.

Arguments:
  • nameSpace (NameSpace)

  • name (string)

TypeName.compare(other)

Return -1, 0 or 1. Throws if other is not a TypeName.

Arguments:
  • other (TypeName)

Returns:

number

TypeName.equals(other)

Return true if both are equal. other of another type answers false.

Arguments:
  • other (unknown)

Returns:

boolean

TypeName.hashKey()
A value-identity key for a native Map or Set, following equals: the namespace’s

uuid and the name. representation() is not one - two namespaces may share a name. A hash, so collisions are possible but negligible.

Returns:

bigint

TypeName.name()

Return the name alone, without the namespace it sits in.

Returns:

string

TypeName.nameSpace()

Return the namespace.

Returns:

NameSpace

TypeName.representation()

Return the name qualified by its namespace, App::Profile.

The bare name for a type of the global namespace. Where a shorter spelling may still be unambiguous, DefinitionsInspector.representation answers that instead, knowing what else is registered.

It is a name, not an identity: two namespaces may share one.

Returns:

string

TypeName.representationIn(nameSpace)

Return the name as written from inside nameSpace.

The bare name when it sits in that namespace, the qualified one otherwise.

Arguments:
  • nameSpace (NameSpace)

Returns:

string

class TypeVoid()

The void type.

Use the static property Type.VOID.

exported from index.d

Extends:
  • Type

TypeVoid.typeName()

Return the TypeName: the built-in name, in the global namespace.

Returns:

TypeName

class TypeBool()

The bool type.

Use the static property Type.BOOL.

exported from index.d

Extends:
  • Type

TypeBool.typeName()

Return the TypeName: the built-in name, in the global namespace.

Returns:

TypeName

class TypeUInt8()

The uint8 type.

Use the static property Type.UINT8.

exported from index.d

Extends:
  • Type

TypeUInt8.typeName()

Return the TypeName: the built-in name, in the global namespace.

Returns:

TypeName

class TypeUInt16()

The uint16 type.

Use the static property Type.UINT16.

exported from index.d

Extends:
  • Type

TypeUInt16.typeName()

Return the TypeName: the built-in name, in the global namespace.

Returns:

TypeName

class TypeUInt32()

The uint32 type.

Use the static property Type.UINT32.

exported from index.d

Extends:
  • Type

TypeUInt32.typeName()

Return the TypeName: the built-in name, in the global namespace.

Returns:

TypeName

class TypeUInt64()

The uint64 type.

Use the static property Type.UINT64.

exported from index.d

Extends:
  • Type

TypeUInt64.typeName()

Return the TypeName: the built-in name, in the global namespace.

Returns:

TypeName

class TypeInt8()

The int8 type.

Use the static property Type.INT8.

exported from index.d

Extends:
  • Type

TypeInt8.typeName()

Return the TypeName: the built-in name, in the global namespace.

Returns:

TypeName

class TypeInt16()

The int16 type.

Use the static property Type.INT16.

exported from index.d

Extends:
  • Type

TypeInt16.typeName()

Return the TypeName: the built-in name, in the global namespace.

Returns:

TypeName

class TypeInt32()

The int32 type.

Use the static property Type.INT32.

exported from index.d

Extends:
  • Type

TypeInt32.typeName()

Return the TypeName: the built-in name, in the global namespace.

Returns:

TypeName

class TypeInt64()

The int64 type.

Use the static property Type.INT64.

exported from index.d

Extends:
  • Type

TypeInt64.typeName()

Return the TypeName: the built-in name, in the global namespace.

Returns:

TypeName

class TypeFloat()

The float type.

Use the static property Type.FLOAT.

exported from index.d

Extends:
  • Type

TypeFloat.typeName()

Return the TypeName: the built-in name, in the global namespace.

Returns:

TypeName

class TypeDouble()

The double type.

Use the static property Type.DOUBLE.

exported from index.d

Extends:
  • Type

TypeDouble.typeName()

Return the TypeName: the built-in name, in the global namespace.

Returns:

TypeName

class TypeString()

The string type.

Use the static property Type.STRING.

exported from index.d

Extends:
  • Type

TypeString.typeName()

Return the TypeName: the built-in name, in the global namespace.

Returns:

TypeName

class TypeBlob()

The blob type.

Use the static property Type.BLOB.

exported from index.d

Extends:
  • Type

TypeBlob.typeName()

Return the TypeName: the built-in name, in the global namespace.

Returns:

TypeName

class TypeBlobId()

The blob_id type.

Use the static property Type.BLOB_ID.

exported from index.d

Extends:
  • Type

TypeBlobId.typeName()

Return the TypeName: the built-in name, in the global namespace.

Returns:

TypeName

class TypeCommitId()

The commit_id type.

Use the static property Type.COMMIT_ID.

exported from index.d

Extends:
  • Type

TypeCommitId.typeName()

Return the TypeName: the built-in name, in the global namespace.

Returns:

TypeName

class TypeUUId()

The uuid type.

Use the static property Type.UUID.

exported from index.d

Extends:
  • Type

TypeUUId.typeName()

Return the TypeName: the built-in name, in the global namespace.

Returns:

TypeName

class TypeVector(elementType)

The vector<elementType> type.

elementType() is the Type it holds; ValueVector builds values of it.

exported from index.d

Extends:
  • Type

Arguments:
  • elementType (Type)

TypeVector.elementType()

Return the type of the elements the vector holds.

Returns:

Type

static TypeVector.cast(type)

Return type as a TypeVector, or throw if it is not one.

Arguments:
  • type (Type)

Returns:

TypeVector

class TypeSet(elementType)

The set<elementType> type.

elementType() is the Type of its elements; ValueSet builds values of it.

exported from index.d

Extends:
  • Type

Arguments:
  • elementType (Type)

TypeSet.elementType()

Return the type of the elements the set holds.

Returns:

Type

TypeSet.elementsType()

Return vector<elementType>, the type a whole element listing has.

Returns:

TypeVector

static TypeSet.cast(type)

Return type as a TypeSet, or throw if it is not one.

Arguments:
  • type (Type)

Returns:

TypeSet

class TypeMap(keyType, elementType)

The map<keyType, elementType> type.

keyType() and elementType() are the two Types it pairs; ValueMap builds values of it.

exported from index.d

Extends:
  • Type

Arguments:
  • keyType (Type)

  • elementType (Type)

TypeMap.elementType()

Return the type of the values the map holds - keyType() gives the keys.

Returns:

Type

TypeMap.itemType()

Return tuple<keyType, elementType>, the type of one entry.

Returns:

TypeTuple

TypeMap.itemsType()

Return vector<itemType>, the type a whole entry listing has.

Returns:

TypeVector

TypeMap.keyType()

Return the type of the keys the map is indexed by.

Returns:

Type

TypeMap.keysType()

Return set<keyType>, the type a whole key listing has.

Returns:

TypeSet

TypeMap.valuesType()

Return vector<elementType>, the type a whole value listing has.

Returns:

TypeVector

static TypeMap.cast(type)

Return type as a TypeMap, or throw if it is not one.

Arguments:
  • type (Type)

Returns:

TypeMap

class TypeXArray(elementType)

The xarray<elementType> type.

elementType() is the Type of its elements; ValueXArray builds values of it.

exported from index.d

Extends:
  • Type

Arguments:
  • elementType (Type)

TypeXArray.elementType()

Return the type of the elements the xarray holds.

Returns:

Type

TypeXArray.elementsType()

Return vector<elementType>, the type a whole element listing has.

Returns:

TypeVector

static TypeXArray.cast(type)

Return type as a TypeXArray, or throw if it is not one.

Arguments:
  • type (Type)

Returns:

TypeXArray

class TypeOptional(elementType)

The optional<elementType> type.

elementType() is the Type it wraps; ValueOptional builds values of it.

exported from index.d

Extends:
  • Type

Arguments:
  • elementType (Type)

TypeOptional.elementType()

Return the type of the value held when the optional is not nil.

Returns:

Type

static TypeOptional.cast(type)

Return type as a TypeOptional, or throw if it is not one.

Arguments:
  • type (Type)

Returns:

TypeOptional

class TypeTuple(types)

The tuple<T0, …> type.

types() gives the component types, in order; ValueTuple builds values of it.

exported from index.d

Extends:
  • Type

Arguments:
  • types (Type[])

TypeTuple.types()

Return the list of types.

Returns:

Type[]

static TypeTuple.cast(type)

Return type as a TypeTuple, or throw if it is not one.

Arguments:
  • type (Type)

Returns:

TypeTuple

class TypeVec(numericType, size)

The vec<numericType, size> type.

numericType is one of the integer or floating-point primitives, Type.UINT8 through Type.DOUBLE; Type.BOOL and Type.STRING throw. size is at least 1, and 0 throws. The accessor that reads numericType back is elementType(), and ValueVec builds values of it.

exported from index.d

Extends:
  • Type

Arguments:
  • numericType (NumericType)

  • size (number)

TypeVec.elementType()

Return the numeric type of one component.

Returns:

NumericType

TypeVec.elementsType()

Return vector<elementType>, the type a whole component listing has.

Returns:

TypeVector

TypeVec.size()

Return the number of components.

Returns:

number

static TypeVec.cast(type)

Return type as a TypeVec, or throw if it is not one.

Arguments:
  • type (Type)

Returns:

TypeVec

class TypeMat(numericType, columns, rows)

The mat<numericType, columns, rows> type.

numericType is one of the integer or floating-point primitives, Type.UINT8 through Type.DOUBLE; Type.BOOL and Type.STRING throw. columns and rows are each at least 1, and 0 throws. The accessor that reads numericType back is elementType(), and ValueMat builds values of it. A value is stored column-major: it lists its columns, each of rows elements.

exported from index.d

Extends:
  • Type

Arguments:
  • numericType (NumericType)

  • columns (number)

  • rows (number)

TypeMat.columns()

Return the number of columns.

Returns:

number

TypeMat.elementType()

Return the numeric type of one component.

Returns:

NumericType

TypeMat.elementsType()

Return vector<elementType>, the type a whole component listing has.

Returns:

TypeVector

TypeMat.rows()

Return the number of rows.

Returns:

number

static TypeMat.cast(type)

Return type as a TypeMat, or throw if it is not one.

Arguments:
  • type (Type)

Returns:

TypeMat

class TypeVariant(types)

The variant<T0, …> type.

types() gives the alternatives, each a Type; ValueVariant builds values of it.

exported from index.d

Extends:
  • Type

Arguments:
  • types (Type[])

TypeVariant.types()

Return the list of types.

Returns:

Type[]

static TypeVariant.cast(type)

Return type as a TypeVariant, or throw if it is not one.

Arguments:
  • type (Type)

Returns:

TypeVariant

class TypeAny()

The any type.

Use the static property Type.ANY.

exported from index.d

Extends:
  • Type

TypeAny.typeName()

Return the TypeName: the built-in name, in the global namespace.

Returns:

TypeName

class TypeStructure()

A struct type.

Definitions.createStructure() makes one from a TypeStructureDescriptor, under a NameSpace.

Note: Not directly instantiable.

exported from index.d

Extends:
  • Type

TypeStructure.check(fieldName)

Return the field called fieldName, or throw if the struct has none.

Arguments:
  • fieldName (string)

Returns:

TypeStructureField

TypeStructure.documentation()

Return the documentation the type was created with, empty when none was given.

Returns:

string

TypeStructure.fields()

Return the list of fields.

Returns:

TypeStructureField[]

TypeStructure.isCompact()

Return true if every field is a bool or a number.

A document tree shows such a structure on one line. Compact is not sized: a vec or a uuid field has a fixed size and is not compact.

Returns:

boolean

TypeStructure.query(fieldName)

Return the field called fieldName, or undefined if the struct has none.

Arguments:
  • fieldName (string)

Returns:

TypeStructureField | undefined

TypeStructure.typeName()

Return the TypeName: the namespace and the name the type was declared under.

Returns:

TypeName

static TypeStructure.cast(type)

Return type as a TypeStructure, or throw if it is not one.

Arguments:
  • type (Type)

Returns:

TypeStructure

class TypeStructureDescriptor(name, documentation)

Describes the fields a struct will be created with.

Definitions.createStructure() turns the descriptor into a TypeStructure.

exported from index.d

Arguments:
  • name (string)

  • documentation (string | null)

TypeStructureDescriptor.addField(fieldName, type, documentation)

Add a field called fieldName to the struct being described.

type is the field type. documentation is carried onto the field.

Arguments:
  • fieldName (string)

  • type (Type)

  • documentation (string | null)

TypeStructureDescriptor.description()

Return the type spelled out: its fields, then its name.

It reads {}:Name while no field has been added - a shape createStructure refuses, a struct requiring at least one field.

Returns:

string

TypeStructureDescriptor.documentation()

Return the documentation the struct will be created with, empty when none was given.

Returns:

string

TypeStructureDescriptor.fields()

Return the list of fields.

Returns:

TypeStructureField[]

TypeStructureDescriptor.name()

Return the name the struct will be created under.

Returns:

string

class TypeStructureField()

One field of a struct type, as TypeStructure.fields(), query() and check() answer it.

Note: Not directly instantiable.

exported from index.d

TypeStructureField.defaultValue(encoded)

Return the default value or undefined.

It is undefined also when the declared default is the type’s own zero - 0, “”, false, the first case of an enumeration: such a default is not kept, since a new structure holds that value anyway.

Passing encoded false returns a Value rather than a native JS value.

Arguments:
  • encoded (false)

Returns:

Value | undefined

TypeStructureField.documentation()

Return the documentation the field was created with, empty when none was given.

Returns:

string

TypeStructureField.name()

Return the field name as declared.

Returns:

string

TypeStructureField.type()

Return the type the field is declared with.

Returns:

Type

class TypeEnumeration()

An enum type.

Note: Not directly instantiable.

exported from index.d

Extends:
  • Type

TypeEnumeration.cases()

Return the list of cases.

Returns:

TypeEnumerationCase[]

TypeEnumeration.check(name)

Return the case called name, or throw if the enum has none.

Arguments:
  • name (string)

Returns:

TypeEnumerationCase

TypeEnumeration.documentation()

Return the documentation the enum was created with, empty when none was given.

Returns:

string

TypeEnumeration.query(name)

Return the case called name, or undefined if the enum has none.

Arguments:
  • name (string)

Returns:

TypeEnumerationCase | undefined

TypeEnumeration.typeName()

Return the TypeName: the namespace and the name the type was declared under.

Returns:

TypeName

static TypeEnumeration.cast(type)

Return type as a TypeEnumeration, or throw if it is not one.

Arguments:
  • type (Type)

Returns:

TypeEnumeration

class TypeEnumerationCase()

One case of an enum type, as TypeEnumeration.cases(), query() and check() answer it.

Note: Not directly instantiable.

exported from index.d

TypeEnumerationCase.documentation()

Return the documentation the case was created with, empty when none was given.

Returns:

string

TypeEnumerationCase.name()

Return the case name as declared.

Returns:

string

class TypeEnumerationDescriptor(name, documentation)

Describes the cases an enum will be created with.

Definitions.createEnumeration() turns the descriptor into a TypeEnumeration.

exported from index.d

Arguments:
  • name (string)

  • documentation (string | null)

TypeEnumerationDescriptor.addCase(name, documentation)

Add a case called name to the enum being described.

documentation is carried onto the case.

Arguments:
  • name (string)

  • documentation (string | null)

TypeEnumerationDescriptor.cases()

Return the list of cases.

Returns:

TypeEnumerationCase[]

TypeEnumerationDescriptor.description()

Return the type spelled out: its cases, then its name.

It reads {}:Name while no case has been added - a shape createEnumeration refuses, an enum requiring at least one case.

Returns:

string

TypeEnumerationDescriptor.documentation()
Return the documentation the enumeration will be created with, empty when none was

given.

Returns:

string

TypeEnumerationDescriptor.name()

Return the name the enum will be created under.

Returns:

string

class TypeConcept()
A concept type: a kind of thing the model names, whose instances keys address and

attachments file documents under.

A concept holds no data itself; what an instance carries is in the documents its attachments hold. A concept may specialise a parent, and a key of the child then widens to a key of the parent. Definitions.createConcept makes one.

Note: Not directly instantiable.

exported from index.d

Extends:
  • Type

TypeConcept.documentation()

Return the documentation the concept was created with, empty when none was given.

Returns:

string

TypeConcept.isMember(typeConcept)

Return true if typeConcept is this concept or one of its ancestors.

Following parent() upwards from this concept reaches typeConcept. TypeClub.isMember asks another question: whether the argument is listed in members(), where a concept specialising a member is not.

Arguments:
  • typeConcept (TypeConcept)

Returns:

boolean

TypeConcept.parent()

Return the parent concept or undefined.

Returns:

TypeConcept | undefined

TypeConcept.typeName()

Return the TypeName: the namespace and the name the type was declared under.

Returns:

TypeName

static TypeConcept.cast(type)

Return type as a TypeConcept, or throw if it is not one.

Arguments:
  • type (Type)

Returns:

TypeConcept

class TypeClub()
A club type: a named list of concepts, so that one key type can address an instance of

any of them.

Definitions.createClub makes one and createMembership adds a concept to it; a key of the club holds a key of one of its members.

Note: Not directly instantiable.

exported from index.d

Extends:
  • Type

TypeClub.documentation()

Return the documentation the club was created with, empty when none was given.

Returns:

string

TypeClub.isMember(typeConcept)

Return true if typeConcept is one of members().

A concept that specialises a member is not one: membership is the list createMembership builds, and parent() is not followed. TypeConcept.isMember asks another question, whether the receiver specialises the argument.

Arguments:
  • typeConcept (TypeConcept)

Returns:

boolean

TypeClub.members()

Return the list of concepts.

Returns:

TypeConcept[]

TypeClub.typeName()

Return the TypeName: the namespace and the name the type was declared under.

Returns:

TypeName

static TypeClub.cast(type)

Return type as a TypeClub, or throw if it is not one.

Arguments:
  • type (Type)

Returns:

TypeClub

class TypeKey(elementType)

The key<elementType> type.

elementType() is a concept, a club or any_concept - isConcept(), isClub() and isAnyConcept() say which; ValueKey builds values of it.

Where a container’s elementType is what it holds, a key’s is what it refers to: a key holds an instance id, never the concept itself.

exported from index.d

Extends:
  • Type

Arguments:
  • elementType (Type)

TypeKey.elementType()

Return the abstraction the key names: a concept, a club or any_concept.

isConcept(), isClub() and isAnyConcept() say which.

Returns:

Type

TypeKey.isAnyConcept()

Return true if elementType is any_concept.

Returns:

boolean

TypeKey.isClub()

Return true if elementType is a club.

Returns:

boolean

TypeKey.isConcept()

Return true if elementType is a concept.

Returns:

boolean

static TypeKey.cast(type)

Return type as a TypeKey, or throw if it is not one.

Arguments:
  • type (Type)

Returns:

TypeKey

class TypeAnyConcept()

The any_concept type.

Use the static property Type.ANY_CONCEPT.

exported from index.d

Extends:
  • Type

TypeAnyConcept.typeName()

Return the TypeName: the built-in name, in the global namespace.

Returns:

TypeName