git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #397 from garyb/master

Add missing Ord instances, don't export `impl` stuff from Prelude

commit10713bd83e9761eb91cb9f064e46a6441b0aedcb authorGary Burgess <gary.burgess@gmail.com> dateTue 29 Apr 2014, 22:16 (13 years ago) parentb0bf43e432f614
1 file changed+43−6
prelude/prelude.purs+43−6
prelude/prelude.purs+43−6
@@ -1,4 +1,27 @@
1−module Prelude where
1+module Prelude
2+ ( flip
3+ , const
4+ , asTypeOf
5+ , Semigroupoid, (<<<), (>>>)
6+ , Category, id
7+ , ($), (#)
8+ , (:), cons
9+ , Show, show
10+ , Functor, (<$>)
11+ , Apply, (<*>)
12+ , Applicative, pure, liftA1
13+ , Alternative, empty, (<|>)
14+ , Bind, (>>=)
15+ , Monad, return, liftM1, ap
16+ , Num, (+), (-), (*), (/), (%)
17+ , negate
18+ , Eq, (==), (/=), refEq, refIneq
19+ , Ord, Ordering(..), compare, (<), (>), (<=), (>=)
20+ , Bits, (&), (|), (^), shl, shr, zshr, complement
21+ , BoolLike, (&&), (||)
22+ , not
23+ , Semigroup, (<>), (++)
24+ ) where
225
326 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
427 flip f b a = f a b
@@ -268,15 +291,29 @@ module Prelude where
268291 LT -> false
269292 _ -> true
270293
271− foreign import numCompare
272− "function numCompare(n1) {\
294+ foreign import unsafeCompare
295+ "function unsafeCompare(n1) {\
273296 \ return function(n2) {\
274297 \ return n1 < n2 ? LT : n1 > n2 ? GT : EQ;\
275298 \ };\
276− \}" :: Number -> Number -> Ordering
277−
299+ \}" :: forall a. a -> a -> Ordering
300+
301+ instance ordBoolean :: Ord Boolean where
302+ compare false false = EQ
303+ compare false true = LT
304+ compare true true = EQ
305+ compare true false = GT
306+
278307 instance ordNumber :: Ord Number where
279− compare = numCompare
308+ compare = unsafeCompare
309+
310+ instance ordString :: Ord String where
311+ compare = unsafeCompare
312+
313+ instance ordArray :: (Ord a) => Ord [a] where
314+ compare (x:xs) (y:ys) = case compare x y of
315+ EQ -> compare xs ys
316+ other -> other
280317
281318 infixl 10 &
282319 infixl 10 |