File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
src/Data/Unfoldable1/Trivial1 Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -189,8 +189,8 @@ instance trivial1Semigroup :: Semigroup (Trivial1 a) where
189
189
instance trivial1Eq :: Eq a => Eq (Trivial1 a ) where
190
190
eq = eq1
191
191
192
- -- instance trivial1Ord :: Ord a => Ord (Trivial1 a) where
193
- -- compare = compare1
192
+ instance trivial1Ord :: Ord a => Ord (Trivial1 a ) where
193
+ compare = compare1
194
194
195
195
instance trivial1Eq1 :: Eq1 Trivial1 where
196
196
eq1 :: forall a . Eq a => Trivial1 a -> Trivial1 a -> Boolean
@@ -199,5 +199,18 @@ instance trivial1Eq1 :: Eq1 Trivial1 where
199
199
eEq1 f b f' b' =
200
200
case f b /\ f' b' of
201
201
(a /\ Nothing ) /\ a' /\ Nothing -> a == a'
202
- (a /\ Just nb) /\ a' /\ Just nb' -> a == a' && eEq1 f nb f' nb'
202
+ (a /\ Just nb) /\ a' /\ Just nb'
203
+ | a == a' -> eEq1 f nb f' nb' -- && does short circuit but I don't want to count on it
203
204
_ -> false
205
+
206
+ instance trivial1Ord1 :: Ord1 Trivial1 where
207
+ compare1 :: forall a . Ord a => Trivial1 a -> Trivial1 a -> Ordering
208
+ compare1 t1 = untrivial1 (untrivial1 eCompare1 t1)
209
+ where eCompare1 :: forall b b' . Generator1 a b -> b -> Generator1 a b' -> b' -> Ordering
210
+ eCompare1 f b f' b' =
211
+ case f b /\ f' b' of
212
+ (a /\ Nothing ) /\ a' /\ Nothing -> a `compare` a'
213
+ (a /\ Just nb) /\ a' /\ Just nb'
214
+ | a == a' -> eCompare1 f nb f' nb'
215
+ _ /\ _ /\ Nothing -> LT
216
+ _ /\ _ /\ Just _ -> GT
You can’t perform that action at this time.
0 commit comments