relude-0.4.0: Custom prelude from Kowainik

Copyright(c) 2018 Kowainik
LicenseMIT
MaintainerKowainik <xrom.xkov@gmail.com>
Safe HaskellSafe
LanguageHaskell2010

Relude.Extra.Tuple

Description

Contains utility functions for working with tuples.

Synopsis

Documentation

dupe :: a -> (a, a) Source #

Creates a tuple by pairing something with itself.

>>> dupe "foo"
("foo","foo")
>>> dupe ()
((),())

mapToFst :: (a -> b) -> a -> (b, a) Source #

Apply a function, with the result in the fst slot, and the value in the other.

A dual to mapToSnd

>>> mapToFst (+1) 10
(11,10)

mapToSnd :: (a -> b) -> a -> (a, b) Source #

Apply a function, with the result in the second slot, and the value in the other.

A dual to mapToFst.

>>> mapToSnd (+1) 10
(10,11)

mapBoth :: (a -> b) -> (a, a) -> (b, b) Source #

Maps a function over both elements of a tuple.

>>> mapBoth ("Hello " <>) ("Alice", "Bob")
("Hello Alice","Hello Bob")