Better comparison for values.
This commit is contained in:
parent
ba8a5c78bb
commit
8b6ebce8e7
|
@ -371,9 +371,10 @@ instance FromJSON Defs where
|
|||
|
||||
compareValue :: Aeson.Value -> Aeson.Value -> Ordering
|
||||
compareValue v0 v1 = case (v0, v1) of
|
||||
-- This case is buggy:
|
||||
(Object o0, Object o1) -> compare (fst <$> toList o0) (fst <$> toList o1)
|
||||
(Aeson.Array a0, Aeson.Array a1) -> foldMap (uncurry compareValue) $ zip (toList a0) (toList a1)
|
||||
(Object o0, Object o1) -> mconcat $ zipWith go (toList o0) (toList o1)
|
||||
where
|
||||
go (t0, v0') (t1, v1') = compare t0 t1 <> compareValue v0' v1'
|
||||
(Aeson.Array a0, Aeson.Array a1) -> mconcat $ zipWith compareValue (toList a0) (toList a1)
|
||||
(Aeson.String s0, Aeson.String s1) -> compare s0 s1
|
||||
(Number n0, Number n1) -> compare n0 n1
|
||||
(Bool b0, Bool b1) -> compare b0 b1
|
||||
|
|
Loading…
Reference in a new issue