Tour: Basic Types

\Text is the default type for the output. Unless we specify something else, our input must be an expression of type \Text. You may have noticed that we have never written a Record value to the output, this is why.

\Text is a textual type, with the prototype \Textual. We can define other textual types that only allow specific characters in them.

We have also seen numeric types, with the prototype \Numeric. \Integer is a predefined numeric type.

The prototype \Enum generates enumeration types, which are used for example for the predefined \Bool type.

Nyarna calls these types scalar types. Each scalar type can be called to create an instance of it.

Each prototype defines a set of functions that are defined on each type generated by this prototype. For example, each textual type has a function len, and each numeric type has a function gt (greater than). These functions are currently sparse, since the standard library has not been seriously worked on yet.

Where \Text is expected, you can give any scalar value and Nyarna will convert it to text.

Details

Nyarna has a static type system. Each symbol, parameter and variable has a type that can't be changed dynamically.

Nyarna's types form a hierarchy called a lattice. This means that if a ≤ b for two types a and b, you can use expressions of type a everywhere expressions of type b are expected.

For any type a that is either textual, numeric, or an enumeration, a ≤ \Text is true.