Overview

A dictionary is a map of key-value pairs ordered by key. (,) represents an empty dictionary. Type expression that represents a dictionary with keys of type A and values of type B is A->>B.

Example:

A is int->>int = (,). // construct an empty dictionary
A 1 -> 2. // Mutate A to introduce a key-value pair (1->2)

Compiler will infer an empty record type from empty dictionary

Use dictionaries to represent:

Arrays

Arrays are represented as dictionaries whose keys are integer values.

Example:

A is str[] = ["hello", "world"]. // Define an array of strings and initialize it with two elements
B = (0->"hello", 1->"world"). // Define a synonymous dictionary
_assert (A == B). // This assertion passes because A and B are identical.

Arrays are not required to be contiguous. In fact, there is a syntax for initializing non-contiguous arrays:

A = ["hello", 2->"world"]. // Misses element 1

Sets

Sets are dictionaries of key-value pairs in which the value is a boolean. Type expression that represents a set of type A is A(,). Checking if an element belongs to a set is simply achieved with a reduction S e where S is the set and e is the element being checked.

SetOfStrings is str(,) = ("hello", "world"). // Define a set of strings. 
// Equivalently: 
EquivalentSetOfStrings is (str->>true+) = ("hello"->TRUE, "world"->TRUE). 
// Checking for presence of value in a set is trivial: 
_assert (SetOfStrings "hello"). 
_assert !(SetOfStrings "goodbye").