diff --git a/src/Data/Language/Ruby/AST.hs b/src/Data/Language/Ruby/AST.hs index 8eadf63..4ac6ee7 100644 --- a/src/Data/Language/Ruby/AST.hs +++ b/src/Data/Language/Ruby/AST.hs @@ -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