This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.

Tuple019

Elm 0.19 added pair and mapBoth.

pair : a -> b -> ( a, b )

Create a 2-tuple.

pair 3 4 --> (3, 4)

zip : List a -> List b -> List (a, b)
zip xs ys =
  List.map2 Tuple.pair xs ys
mapBoth : (a -> x) -> (b -> y) -> ( a, b ) -> ( x, y )

Transform both parts of a tuple.

mapBoth String.reverse sqrt  ("stressed", 16) --> ("desserts", 4)

mapBoth String.length negate ("stressed", 16) --> (8, -16)
module Tuple019 exposing (pair, mapBoth)

{-| Elm 0.19 added `pair` and `mapBoth`.

@docs pair, mapBoth

-}


{-| Create a 2-tuple.

    pair 3 4 --> (3, 4)

    zip : List a -> List b -> List (a, b)
    zip xs ys =
      List.map2 Tuple.pair xs ys

-}
pair : a -> b -> ( a, b )
pair a b =
    ( a, b )


{-| Transform both parts of a tuple.

    mapBoth String.reverse sqrt  ("stressed", 16) --> ("desserts", 4)

    mapBoth String.length negate ("stressed", 16) --> (8, -16)

-}
mapBoth : (a -> x) -> (b -> y) -> ( a, b ) -> ( x, y )
mapBoth funcA funcB ( x, y ) =
    ( funcA x, funcB y )