The type system enables you to declare what type of data a port in your component uses. You can declare primitive types - boolean, integer, float, string, null, type or tag. There are also types that are containers: list, set, multiset, entity, nullable and dynamicThe container types contain other types, both primitive and other containers. 

All these types can be used to define what kind of value is expected as an input on a component, or promised by an output. They are also used to declare argument type for components.

This article will walk you through how to use them when building a component, and it provides a reference for understanding and using specific types. 


 How and Where


The type system gets used when creating or editing inputs and outputs for a component, e.g.


qcLD4bemd9TiRwtA2fAEDlibUikGp_ru3A.png

If you want more detail about user interface, check out the separate article to learn more about the component editor interface.


 

The Primitive Types

 

The building blocks of the type system are the primitive types.



Type
Declaration Syntax
Allowable Values
boolean
boolean
true or false 
integer
integer
any integer from -(2^53 - 1) to (2^53 - 1)
float
float 

 64-bit floating point (IEEE 754)


string
string
unicode
tag
tag
true or null
null
null
null
type
type
any type



The Container Types


Then there are the container types, which provide parameters for other types.


Entities


Entity is an important concept to the Exaptive data model. They are similar to objects in javascript or record types in python. In the sample script below, attrN signifies the name of an attribute. Tn is the type, which may be different for each attribute of an entity. The attributes in an entity are ordered, and two entities with the same attributes but in different order are considered to be of different types. 


declaration syntax: entity<T1 attr1, T2 attr2, ...> 


 

Collections: List, Set, and Multiset


Collection types allow values that hold zero or more instances of a primitive type. All items in a collection must be of the same type. There are three kinds of collections. In the snippets, T is the type in the collection.


A list is an ordered collection:


declaration syntax: list<T>


A set is an unordered collections that do not allow duplicate values.


declaration syntax: set<T>  


A multiset is unordered collections.


declaration syntax: set<T>


 

Dynamic

 

Dynamic is a type that can hold values of any type. The value that is held in a dynamic still has its own type. But, for instance, if you declare a list - list<dynamic>  - you have a list that can hold any kind of value.   

 

declaration syntax: dynamic

allowable values: any value from any other type

 

Nullable

 

Nullable type allows a value to be any value from a primitive type, including null. You can declare nullable using angle brackets or by putting a question mark after any type. 

  

declaration syntax: nullable<T> or T?

allowable values: value from base type, or null

 

Nullable may be more accurately dubbed a condition, instead of a container. But it functions similarly in that it provides a parameter for other types.


NOTE: You'll notice with the container types that you declare container types without declaring all the attributes they contain. For example, a component's input could be defined to accept: multiset<entity>. The component expects to receive a multiset of entities, but it does not care what the attributes of the entity  are. The system will resolve the unknown part of the type to an actual type. The partial type resolution happens at the type level, not the value level. So all of the entities in the multiset  will share the same entity type.   


NOTE: You'll rarely use the type type, but it's good to know it exists. The type type  holds a value that is a type. Read that again. It does actually make sense. For example, integer, set<string> and entity<string name, float? score> are all legal values in the type type It might be helpful to compare it to dynamic. Dynamic holds primitive values, like 5 or nullType only holds values that are themselves types.