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

Pair

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: In future versions of Silver, we may add syntactic sugar for pairs as (3, "OH NO!"). And similarly for types. However, this is not present yet.