Tuples are ordered lists of values of any type.
(True, "Hello!", 42)
It is impossible to change the structure of a Tuple or update the value.
Tuples in Elm are considered a primitive data type, which means that you don't need to import any modules to use Tuples.
Basics module has two helper functions for accessing values of a Tuple with a length of two ( a, b )
without using pattern matching:
fst (True, "Hello!") -- True
snd (True, "Hello!") -- "Hello!"
Access values of tuples with a bigger length is done through pattern matching.
Tuples are extremely useful in combination with pattern matching:
toggleFlag: (Sting, Bool) -> (Sting, Bool)
toggleFlag (name, flag) =
(name, not flag)
Tuples contain less than 7 values of comparable
data type