Safe Haskell | Safe-Inferred |
---|
Extra functions for working with tuples. Some of these functions are available in the Control.Arrow module, but here are available specialised to pairs.
Specialised Arrow
functions
first :: (a -> a') -> (a, b) -> (a', b)Source
Update the first component of a pair.
first succ (1,"test") == (2,"test")
second :: (b -> b') -> (a, b) -> (a, b')Source
Update the second component of a pair.
second reverse (1,"test") == (1,"tset")
(***) :: (a -> a') -> (b -> b') -> (a, b) -> (a', b')Source
Given two functions, apply one to the first component and one to the second.
A specialised version of ***
.
(succ *** reverse) (1,"test") == (2,"tset")
(&&&) :: (a -> b) -> (a -> c) -> a -> (b, c)Source
Given two functions, apply both to a single argument to form a pair.
A specialised version of &&&
.
(succ &&& pred) 1 == (2,0)
More pair operations
both :: (a -> b) -> (a, a) -> (b, b)Source
Apply a single function to both componenets of a pair.
both succ (1,2) == (2,3)