antelude-0.1.0: Yet another alternative Prelude for Haskell.
Maintainerdneavesdev@pm.me
Safe HaskellSafe
LanguageGHC2021

Antelude.Tuple.Pair

Description

 
Synopsis

Documentation

type Pair a b = (a, b) Source #

A two-element Tuple

curry :: ((a, b) -> c) -> a -> b -> c #

curry converts an uncurried function to a curried function.

Examples

Expand
>>> curry fst 1 2
1

first :: Pair a b -> a Source #

Get the first item of a Pair Tuple

mapFirst :: (a -> z) -> Pair a b -> Pair z b Source #

Apply a function to the first item of a Pair Tuple

mapSecond :: (b -> z) -> Pair a b -> Pair a z Source #

Apply a function to the second item of a Pair Tuple

pack :: a -> b -> Pair a b Source #

Pack both arguments into a Pair Tuple

second :: Pair a b -> b Source #

Get the second item of a Pair Tuple

swap :: Pair a b -> Pair b a Source #

Swap the items in a Pair Tuple

uncurry :: (a -> b -> c) -> (a, b) -> c #

uncurry converts a curried function to a function on pairs.

Examples

Expand
>>> uncurry (+) (1,2)
3
>>> uncurry ($) (show, 1)
"1"
>>> map (uncurry max) [(1,2), (3,4), (6,8)]
[2,4,8]