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:
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.
The syntax which Adama parses for this is as follows:
- 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.
which results in the document persisted and viewed by all with slightly more meaningful data in JSON:
Adama has many built-in types, and the following tables outline which types are available.
|bool||bool can have one of the two values true or false.||false||true|
|int||int is a signed integer number that uses 32-bits. This results in valid values between −2,147,483,648 and 2,147,483,647.||0||42|
|long||long 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.||0||42|
|double||double is a floating-point type which uses 64-bit IEEE754. This results in a range of 1.7E +/- 308 (15 digits).||0.0||3.15|
|string||string is a utf-8 encoded collection of code-points.||"" (empty string)||"Hello World"|
|label||label is a pointer to a block of code which is used by the state machine,||# (the no-state)||#hello|
|client||client 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|
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.
|type||quick call out||applicable to document/record|
|enum||An enumeration is a type that consists of a finite set of named constants.||yes|
|messages||A message is a collection of variables grouped under one name used for communication.||no|
|records||A record is a collection of variables grouped under one name used for persistence.||yes|
|maybe||Sometimes 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)|
|table||A table form the ultimate collection enabling maps, lists, sets, and more. Tables use records to persist information in a structured way.||yes|
|channel||Channels enable communication between the document and people via handlers and futures.||only root document|
|future||A future is a result that will arrive in the future.||no|
|maps||maps enable associating keys to values, but they can also be the result of a reduction.||not yet|
|lists||A list is created by using language integrated query on a table||only via a formula|
|arrays||An array is a finite collection of a adjacent items||no|