Renamed to hayleigh-dot-dev/tuple-extra. It is published under that name, and new versions come out there.
Versions published as pd-andy/tuple-extra still install under that name. 2 versions of 2 come from the new location (see their notes).
Rerouted (cache, verified). The original is gone. This copy comes from a Lamdera package cache made before it went. The Lamdera package server serves a copy recovered from a Lamdera package cache from 2021-02-13.
What we checked: Rebuilt from the unpacked sources in a Lamdera package cache (5 copies agree), which Elm only writes after the published SHA-1 checked out; elm.json is byte-identical to package.elm-lang.org's; the exposed modules match docs.json; the zip is our own, so its SHA-1 is not the published one.
The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.
Details · package.elm-lang.org's zip: https://github.com/pd-andy/tuple-extra/zipball/1.0.1/
In certain situations, this proves more "pipe friendly" than the standard
Tuple.pair. Fits nicely in your update function.
{ model | count = model.count + 1 }
|> Tuple.pairWith Cmd.noneOccasionally you might want to create a Tuple from a single value. This does just that.
Tuple.from 1
== (1, 1)Given a function that takes two arguments, apply that function to the two values contained in a tuple.
Tuple.apply (+) (1, 2)
== 3Flip the two values contained in a tuple.
Similar to String.join but for tuples instead of lists. Given some separator string, join together two strings in a tuple.
Tuple.join " " ("Hello", "world")
== "Hello world"Works just like join, but first converts the values of the tuple to strings. These means the function works with any type of tuple.
Tuple.joinBy String.fromInt suitToString " of " (7, Club)
== "Seven of Clubs"Similar to List.sum but for tuples instead of lists. Adds together two numbers contained in a tuple.
Tuple.sum (1, 2)
== 3Similar to List.sum but for tuples instead of lists. Multiplies together two numbers contained in a tuple
Tuple.product (1, 2)
== 2Similar to List.sort but for tuples instead of lists. Sort values contained in a tuple from lowest to highest
Tuple.sort (2, 1)
== (1, 2)Similar to List.sortBy but for tuples instead of lists. Sort values
contained in a tuple by first converting both values to a comparable. The
values are sorted lowest to highest
Tuple.sortBy String.length ("mouse", "cat")
== ("cat", "mouse")Similar to List.sortWith but for tuples instead of lists. Instead of
converting values contained in a tuple to comparables, instead supply a
function that will produce an Order directly.
Tuple.sortWith Basics.compare (2, 1)
== Tuple.sort (2, 1)
== (1, 2)Apply a function to both values contained in a tuple. This might also be
known as mapBothWith or bimap.
Tuple.map negate (-3, 10)
== (3, -10)Occasionally you might find yourself in a situation where both values
contained in a tuple are Maybes. Sometimes it makes more sense to take those
values and make the tuple a Maybe instead.
Tuple.sequenceMaybe (Just 10, Nothing)
== Nothing
Tuple.sequenceMaybe (Just 10, Just "Cat")
== Maybe (10, "Cat")Similar to sequenceMaybe but only looks at the first value in a tuple
to check for nothingness.
Tuple.sequenceFirstMaybe (Just 10, "Cat")
== Maybe (10, "Cat")Similar to sequenceMaybe but only looks at the first value in a tuple
to check for nothingness.
Tuple.sequenceSecondMaybe (10, Just "Cat")
== Maybe (10, "Cat")
By type aliasing tuples into a "normal" type, we remove the (small) effort required in reading types and signatures that have tuples in. I've found this is most beneficial when a tuple is nested inside another type. Visually, the Tuple type is now no different to List, Maybe, or Result.
For example, this:
becomes: