Elm Language Collecting Data: Tuples, Records and Dictionaries Tuples

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!


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.

Accessing values

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.

Pattern matching

Tuples are extremely useful in combination with pattern matching:

toggleFlag: (Sting, Bool) -> (Sting, Bool)
toggleFlag (name, flag) =
    (name, not flag)

Remarks on Tuples

Tuples contain less than 7 values of comparable data type

Got any Elm Language Question?