@@ -17,7 +17,6 @@ module Data.Ord
1717
1818import Data.Eq (class Eq , class Eq1 , class EqRecord , (/=))
1919import Data.Symbol (class IsSymbol , SProxy (..), reflectSymbol )
20- import Data.Ord.Unsafe (unsafeCompare )
2120import Data.Ordering (Ordering (..))
2221import Data.Ring (class Ring , zero , one , negate )
2322import Data.Unit (Unit )
@@ -39,19 +38,19 @@ class Eq a <= Ord a where
3938 compare :: a -> a -> Ordering
4039
4140instance ordBoolean :: Ord Boolean where
42- compare = unsafeCompare
41+ compare = ordBooleanImpl LT EQ GT
4342
4443instance ordInt :: Ord Int where
45- compare = unsafeCompare
44+ compare = ordIntImpl LT EQ GT
4645
4746instance ordNumber :: Ord Number where
48- compare = unsafeCompare
47+ compare = ordNumberImpl LT EQ GT
4948
5049instance ordString :: Ord String where
51- compare = unsafeCompare
50+ compare = ordStringImpl LT EQ GT
5251
5352instance ordChar :: Ord Char where
54- compare = unsafeCompare
53+ compare = ordCharImpl LT EQ GT
5554
5655instance ordUnit :: Ord Unit where
5756 compare _ _ = EQ
@@ -68,6 +67,46 @@ instance ordArray :: Ord a => Ord (Array a) where
6867 LT -> 1
6968 GT -> -1
7069
70+ foreign import ordBooleanImpl
71+ :: Ordering
72+ -> Ordering
73+ -> Ordering
74+ -> Boolean
75+ -> Boolean
76+ -> Ordering
77+
78+ foreign import ordIntImpl
79+ :: Ordering
80+ -> Ordering
81+ -> Ordering
82+ -> Int
83+ -> Int
84+ -> Ordering
85+
86+ foreign import ordNumberImpl
87+ :: Ordering
88+ -> Ordering
89+ -> Ordering
90+ -> Number
91+ -> Number
92+ -> Ordering
93+
94+ foreign import ordStringImpl
95+ :: Ordering
96+ -> Ordering
97+ -> Ordering
98+ -> String
99+ -> String
100+ -> Ordering
101+
102+ foreign import ordCharImpl
103+ :: Ordering
104+ -> Ordering
105+ -> Ordering
106+ -> Char
107+ -> Char
108+ -> Ordering
109+
71110foreign import ordArrayImpl :: forall a . (a -> a -> Int ) -> Array a -> Array a -> Int
72111
73112instance ordOrdering :: Ord Ordering where
0 commit comments