Package

purescript-pairs

Repository
sharkdp/purescript-pairs
License
MIT
Uploaded by
pacchettibotti
Published on
2023-02-10T20:39:20Z

This module defines a datatype Pair together with a few useful instances and helper functions. Note that this is not just Tuple a a but rather a list with exactly two elements. Specifically, the Functor instance maps over both values in contrast to the Functor instance for Tuple a, which can only map over the second argument.

Example

> let point1 = 2 ~ 3
> let point2 = 4 ~ 7

> sum point1
5

> (+) <$> point1 <*> point2
(6 ~ 10)

> ("Hello" ~ "foo") <> pure " " <> ("World" ~ "bar")
("Hello World" ~ "foo bar")

> collect (\x → x ~ x*x) (1 .. 5)
([1,2,3,4,5] ~ [1,4,9,16,25])
Modules
Data.Pair
Dependencies