| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
NumHask.Pair
Description
I would have used V2 from the linear package, but wanted to avoid the lens dependency. And there's no canonical treatment out there.
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 IntPair 1 1>>>(*) <$> Pair 1 2 <*> pure 2Pair 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 + zeroPair 0 1>>>Pair 0 1 + Pair 2 3Pair 2 4>>>Pair 1 1 - onePair 0 0>>>Pair 0 1 * onePair 0 1>>>Pair 0 1 / onePair 0.0 1.0>>>Pair 11 12 `mod` (pure 6)Pair 5 0
As a numhask module
>>>Pair 1 2 .+ 3Pair 4 5
representables
>>>distribute [Pair 1 2, Pair 3 4]Pair [1,3] [2,4]>>>index (Pair 'l' 'r') False'l'
Constructors
| Pair' (a, a) |
Instances