git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Add missing Ord instances
1ff7151Gary Burgess
prelude/prelude.purs+19−5
@@ -268,15 +268,29 @@ module Prelude where
268 LT -> false
268 LT -> false
269 _ -> true
269 _ -> true
270
270
271− foreign import numCompare
271+ foreign import unsafeCompare
272− "function numCompare(n1) {\
272+ "function unsafeCompare(n1) {\
273 \ return function(n2) {\
273 \ return function(n2) {\
274 \ return n1 < n2 ? LT : n1 > n2 ? GT : EQ;\
274 \ return n1 < n2 ? LT : n1 > n2 ? GT : EQ;\
275 \ };\
275 \ };\
276− \}" :: Number -> Number -> Ordering
276+ \}" :: forall a. a -> a -> Ordering
277−
277+
278+ instance ordBoolean :: Ord Boolean where
279+ compare false false = EQ
280+ compare false true = LT
281+ compare true true = EQ
282+ compare true false = GT
283+
278 instance ordNumber :: Ord Number where
284 instance ordNumber :: Ord Number where
279− compare = numCompare
285+ compare = unsafeCompare
286+
287+ instance ordString :: Ord String where
288+ compare = unsafeCompare
289+
290+ instance ordArray :: (Ord a) => Ord [a] where
291+ compare (x:xs) (y:ys) = case compare x y of
292+ EQ -> compare xs ys
293+ other -> other
280
294
281 infixl 10 &
295 infixl 10 &
282 infixl 10 |
296 infixl 10 |