@@ -14,17 +14,12 @@ module Data.Ord
1414 , module Data.Ordering
1515 ) where
1616
17- import Data.Eq (class Eq , class Eq1 , class EqRecord , (/=))
18- import Data.Internal.Record (unsafeGet )
17+ import Data.Eq (class Eq , class Eq1 )
1918import Data.Ord.Unsafe (unsafeCompare )
2019import Data.Ordering (Ordering (..))
2120import Data.Ring (class Ring , zero , one , negate )
22- import Data.RowList (RLProxy (..))
23- import Data.Symbol (class IsSymbol , SProxy (..), reflectSymbol )
2421import Data.Unit (Unit )
2522import Data.Void (Void )
26- import Prim.Row as Row
27- import Prim.RowList as RL
2823
2924-- | The `Ord` type class represents types which support comparisons with a
3025-- | _total order_.
@@ -174,31 +169,36 @@ class Eq1 f <= Ord1 f where
174169instance ord1Array :: Ord1 Array where
175170 compare1 = compare
176171
177- class EqRecord rowlist row focus <= OrdRecord rowlist row focus | rowlist -> focus where
178- compareImpl :: RLProxy rowlist -> Record row -> Record row -> Ordering
179-
180- instance ordRecordNil :: OrdRecord RL.Nil row focus where
181- compareImpl _ _ _ = EQ
182-
183- instance ordRecordCons
184- :: ( OrdRecord rowlistTail row subfocus
185- , Row.Cons key focus rowTail row
186- , IsSymbol key
187- , Ord focus
188- )
189- => OrdRecord (RL.Cons key focus rowlistTail ) row focus where
190- compareImpl _ ra rb
191- = if left /= EQ
192- then left
193- else compareImpl (RLProxy :: RLProxy rowlistTail ) ra rb
194- where
195- key = reflectSymbol (SProxy :: SProxy key )
196- unsafeGet' = unsafeGet :: String -> Record row -> focus
197- left = unsafeGet' key ra `compare` unsafeGet' key rb
198-
199- instance ordRecord
200- :: ( RL.RowToList row list
201- , OrdRecord list row focus
202- )
203- => Ord (Record row ) where
204- compare = compareImpl (RLProxy :: RLProxy list )
172+ -- Ordering for records is currently unimplemented as there are outstanding
173+ -- questions around whether this implementation be useful. This is because it
174+ -- prioritises the keys alphabetically, and this behaviour isn't overridable.
175+ -- For now, we leave this unavailable, but the implementation is as follows:
176+
177+ -- class EqRecord rowlist row focus <= OrdRecord rowlist row focus | rowlist -> focus where
178+ -- compareImpl :: RLProxy rowlist -> Record row -> Record row -> Ordering
179+ --
180+ -- instance ordRecordNil :: OrdRecord RL.Nil row focus where
181+ -- compareImpl _ _ _ = EQ
182+ --
183+ -- instance ordRecordCons
184+ -- :: ( OrdRecord rowlistTail row subfocus
185+ -- , Row.Cons key focus rowTail row
186+ -- , IsSymbol key
187+ -- , Ord focus
188+ -- )
189+ -- => OrdRecord (RL.Cons key focus rowlistTail) row focus where
190+ -- compareImpl _ ra rb
191+ -- = if left /= EQ
192+ -- then left
193+ -- else compareImpl (RLProxy :: RLProxy rowlistTail) ra rb
194+ -- where
195+ -- key = reflectSymbol (SProxy :: SProxy key)
196+ -- unsafeGet' = unsafeGet :: String -> Record row -> focus
197+ -- left = unsafeGet' key ra `compare` unsafeGet' key rb
198+ --
199+ -- instance ordRecord
200+ -- :: ( RL.RowToList row list
201+ -- , OrdRecord list row focus
202+ -- )
203+ -- => Ord (Record row) where
204+ -- compare = compareImpl (RLProxy :: RLProxy list)
0 commit comments