Document Variables & Types

Fast Intro#

As Adama is a data-centric programming language, the first order of business is to organize your data for state management. At the document level, state is laid out as a series of fields. For instance, the below Adama code outlines three fields:

public string output;
private double balance;
int count;

These three fields will establish a persistent document in JSON:


The public and private modifiers control what users will see, and the omission of either results in private by default. In this case, users will see:


when they connect to the document.

Diving Into Details#

The syntax which Adama parses for this is as follows:

(privacy)? type name (= expression)?;

such that

  • privacy when set may be private, public, or anything outlined in the privacy section. In this context, private means only the system and code within Adama can see the field while public means the system, the code, and any human viewer may see the field. The privacy section will outline other ways for humans to see the field.
  • privacy when omitted results in a default value of private which means no users can see the field.
  • type is the type of the data. See types for more details.
  • expression when provided will be computed at the construction of the document.

The privacy policy of this document is limited and lacks data that users want to and should see. This is unfortunate, but can be corrected by changing the document to

public string output = "Hello World"
private double balance = 13.42;
public int count = 42;

which results in the document persisted and viewed by all with slightly more meaningful data in JSON:

{"output":"Hello World","count":42}

Built-in Types#

Adama has many built-in types, and the following tables outline which types are available.

typecontentsdefaultfun example
boolbool can have one of the two values true or false.falsetrue
intint is a signed integer number that uses 32-bits. This results in valid values between โˆ’2,147,483,648 and 2,147,483,647.042
longlong is a signed integer number that uses 64-bits. This results in valid values between -9,223,372,036,854,775,808 and +9,223,372,036,854,775,807.042
doubledouble is a floating-point type which uses 64-bit IEEE754. This results in a range of 1.7E +/- 308 (15 digits).0.03.15
stringstring is a utf-8 encoded collection of code-points."" (empty string)"Hello World"
labellabel is a pointer to a block of code which is used by the state machine,# (the no-state)#hello
clientclient is a reference to a connected person, and the backing data establishes who they are. This is used for acquiring data and decisions from people,@no_one@no_one

Call-out to other types#

The above built-in types are building blocks for richer types, and the below table provides callouts to other type mechanisms. Not all types are valid at the document level.

typequick call outapplicable to document/record
enumAn enumeration is a type that consists of a finite set of named constants.yes
messagesA message is a collection of variables grouped under one name used for
recordsA record is a collection of variables grouped under one name used for persistence.yes
maybeSometimes things didn't or can't happen, and we use maybe to express that absence rather than null. Monads for the win!yes (only of applicable types)
tableA table form the ultimate collection enabling maps, lists, sets, and more. Tables use records to persist information in a structured way.yes
channelChannels enable communication between the document and people via handlers and futures.only root document
futureA future is a result that will arrive in the
mapsmaps enable associating keys to values, but they can also be the result of a reduction.not yet
listsA list is created by using language integrated query on a tableonly via a formula
arraysAn array is a finite collection of a adjacent itemsno