Minnesota Extensible Language Tools Group
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode

Pair

local attribute symbolDef :: Pair<String Integer>;
symbolDef = pair("a", 3);

Pairs are also provided as a standard data structure in core. Pairs are the first data structure that is completely unspecial–that is, it’s an ordinary nonterminal with no special language support.

The pair type is written Pair<a b> where a and b are types.

Pairs are constructed using the pair constructor:

abstract production pair
top::Pair<a b> ::= f::a  s::b

Example:

local attribute priorityError :: Pair<Integer String>;
priorityError = pair(3, "OH NO!");

The elements are accessed using the fst and snd attributes.

Example:

if priorityError.fst > 2
then print("Error: " ++ priorityError.snd, ioin)
else print("No serious errors.", ioin)

Up to date information about this data structure can be found in core/Pair.sv.

Note: Pairs can be expressed using tuple syntax as (3, "OH NO!"). See the tuples page for more information.