Skip to content

Commit

Permalink
Matching Down instance instead of Min
Browse files Browse the repository at this point in the history
  • Loading branch information
AliceRixte committed Jun 6, 2024
1 parent 57cd653 commit 806a832
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
16 changes: 2 additions & 14 deletions src/Data/Aeson/Types/FromJSON.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 7 additions & 4 deletions src/Data/Aeson/Types/ToJSON.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2101,25 +2101,28 @@ 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
toJSON = toJSON1
toEncoding = toEncoding1
omitField = omitField1


instance ToJSON Monoid.All where
toJSON = toJSON . Monoid.getAll
toEncoding = toEncoding . Monoid.getAll
Expand Down

0 comments on commit 806a832

Please sign in to comment.