Safe Haskell | None |
---|---|
Language | Haskell2010 |
A Pair is *the* classical higher-kinded number but there is no canon.
Documentation
A pair of a's, implemented as a tuple, but api represented as a Pair of a's.
>>>
fmap (+1) (Pair 1 2)
Pair 2 3>>>
pure one :: Pair Int
Pair 1 1>>>
(*) <$> Pair 1 2 <*> pure 2
Pair 2 4>>>
foldr (++) [] (Pair [1,2] [3])
[1,2,3]>>>
Pair "a" "pair" `mappend` pure " " `mappend` Pair "string" "mappended"
Pair "a string" "pair mappended"
As a Ring and Field class
>>>
Pair 0 1 + zero
Pair 0 1>>>
Pair 0 1 + Pair 2 3
Pair 2 4>>>
Pair 1 1 - one
Pair 0 0>>>
Pair 0 1 * one
Pair 0 1>>>
Pair 0.0 1.0 / one
Pair 0.0 1.0>>>
Pair 11 12 `mod` (pure 6)
Pair 5 0
As an action
>>>
Pair 1 2 .+ 3
Pair 4 5
Pair' (a, a) |