From afe5ae3377b4506827a7a1de7cbb8fce2e12cf96 Mon Sep 17 00:00:00 2001 From: autonym8 Date: Thu, 6 Jun 2024 14:34:44 +0200 Subject: [PATCH] Matching Down instance instead of Min --- src/Data/Aeson/Types/FromJSON.hs | 16 ++-------------- src/Data/Aeson/Types/ToJSON.hs | 9 +++++---- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/Data/Aeson/Types/FromJSON.hs b/src/Data/Aeson/Types/FromJSON.hs index 3ccb0d58..ac3e0091 100644 --- a/src/Data/Aeson/Types/FromJSON.hs +++ b/src/Data/Aeson/Types/FromJSON.hs @@ -2335,33 +2335,21 @@ instance FromJSON a => FromJSON (Monoid.Dual a) where parseJSON = parseJSON1 instance FromJSON1 Monoid.Sum where - liftParseJSON _ p _ a = coerce (p a) - - liftParseJSONList _ _ p a = coerce (p a) + liftParseJSON _ p _ = coerce p liftOmittedField = coerce instance (FromJSON a) => FromJSON (Monoid.Sum a) where parseJSON = parseJSON1 - parseJSONList = liftParseJSONList omittedField parseJSON parseJSONList - - omittedField = omittedField1 - instance FromJSON1 Monoid.Product where - liftParseJSON _ p _ a = coerce (p a) - - liftParseJSONList _ _ p a = coerce (p a) + liftParseJSON _ p _ = coerce p liftOmittedField = coerce instance (FromJSON a) => FromJSON (Monoid.Product a) where parseJSON = parseJSON1 - parseJSONList = liftParseJSONList omittedField parseJSON parseJSONList - - omittedField = omittedField1 - instance FromJSON Monoid.All where parseJSON = coerce . (parseJSON :: Value -> Parser Bool) diff --git a/src/Data/Aeson/Types/ToJSON.hs b/src/Data/Aeson/Types/ToJSON.hs index 9cd768b0..30056337 100644 --- a/src/Data/Aeson/Types/ToJSON.hs +++ b/src/Data/Aeson/Types/ToJSON.hs @@ -2101,18 +2101,19 @@ instance ToJSON a => ToJSON (Monoid.Dual a) where omitField = omitField1 instance ToJSON1 Monoid.Sum where - liftToJSON _ t _ = t . Monoid.getSum - liftToEncoding _ t _ = t . Monoid.getSum + liftToJSON _ t _ = coerce t + liftToEncoding _ t _ = coerce t liftOmitField = coerce + instance ToJSON a => ToJSON (Monoid.Sum a) where toJSON = toJSON1 toEncoding = toEncoding1 omitField = omitField1 instance ToJSON1 Monoid.Product where - liftToJSON _ t _ = t . Monoid.getProduct - liftToEncoding _ t _ = t . Monoid.getProduct + liftToJSON _ t _ = coerce t + liftToEncoding _ t _ = coerce t liftOmitField = coerce instance ToJSON a => ToJSON (Monoid.Product a) where