git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #397 from garyb/master
10713bdGary Burgess
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
2
25
3 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
26 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
4 flip f b a = f a b
27 flip f b a = f a b
@@ -268,15 +291,29 @@ module Prelude where
268 LT -> false
291 LT -> false
269 _ -> true
292 _ -> true
270
293
271− foreign import numCompare
294+ foreign import unsafeCompare
272− "function numCompare(n1) {\
295+ "function unsafeCompare(n1) {\
273 \ return function(n2) {\
296 \ return function(n2) {\
274 \ return n1 < n2 ? LT : n1 > n2 ? GT : EQ;\
297 \ return n1 < n2 ? LT : n1 > n2 ? GT : EQ;\
275 \ };\
298 \ };\
276− \}" :: Number -> Number -> Ordering
299+ \}" :: forall a. a -> a -> Ordering
277−
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+
278 instance ordNumber :: Ord Number where
307 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
280
317
281 infixl 10 &
318 infixl 10 &
282 infixl 10 |
319 infixl 10 |