Skip to content

Commit 5746ab0

Browse files
authored
Merge pull request #26 from purescript/eq-ord-1
Add `Eq1` and `Ord1` instances
2 parents 55cbdef + 955fb5a commit 5746ab0

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

bower.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"package.json"
1818
],
1919
"dependencies": {
20-
"purescript-foldable-traversable": "^2.0.0"
20+
"purescript-foldable-traversable": "^2.0.0",
21+
"purescript-prelude": "^2.4.0"
2122
}
2223
}

src/Data/Tuple.purs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ import Control.Lazy (class Lazy, defer)
1212
import Data.Bifoldable (class Bifoldable)
1313
import Data.Bifunctor (class Bifunctor)
1414
import Data.Bitraversable (class Bitraversable)
15+
import Data.Eq (class Eq1)
1516
import Data.Foldable (class Foldable, foldMap)
1617
import Data.Functor.Invariant (class Invariant, imapF)
1718
import Data.HeytingAlgebra (implies, ff, tt)
1819
import Data.Maybe (Maybe(..))
1920
import Data.Maybe.First (First(..))
2021
import Data.Monoid (class Monoid, mempty)
2122
import Data.Newtype (unwrap)
23+
import Data.Ord (class Ord1)
2224
import Data.Traversable (class Traversable)
2325

2426
-- | A simple product type for wrapping a pair of component values.
@@ -33,12 +35,16 @@ instance showTuple :: (Show a, Show b) => Show (Tuple a b) where
3335
-- | there are `Eq` instances for both component types.
3436
derive instance eqTuple :: (Eq a, Eq b) => Eq (Tuple a b)
3537

38+
instance eq1Tuple :: Eq a => Eq1 (Tuple a) where eq1 = eq
39+
3640
-- | Allows `Tuple`s to be compared with `compare`, `>`, `>=`, `<` and `<=`
3741
-- | whenever there are `Ord` instances for both component types. To obtain
3842
-- | the result, the `fst`s are `compare`d, and if they are `EQ`ual, the
3943
-- | `snd`s are `compare`d.
4044
derive instance ordTuple :: (Ord a, Ord b) => Ord (Tuple a b)
4145

46+
instance ord1Tuple :: Ord a => Ord1 (Tuple a) where compare1 = compare
47+
4248
instance boundedTuple :: (Bounded a, Bounded b) => Bounded (Tuple a b) where
4349
top = Tuple top top
4450
bottom = Tuple bottom bottom

0 commit comments

Comments
 (0)