Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 78fcd9b

Browse files
committedJun 11, 2024
collect GOmitFromJSON instances
1 parent ec937de commit 78fcd9b

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed
 

‎src/Data/Aeson/Types/FromJSON.hs

+12-12
Original file line numberDiff line numberDiff line change
@@ -1013,30 +1013,18 @@ instance (FromJSON a) => GFromJSON arity (K1 i a) where
10131013
gParseJSON _opts _ = fmap K1 . parseJSON
10141014
{-# INLINE gParseJSON #-}
10151015

1016-
instance FromJSON a => GOmitFromJSON arity (K1 i a) where
1017-
gOmittedField _ = fmap K1 omittedField
1018-
{-# INLINE gOmittedField #-}
1019-
10201016
instance GFromJSON One Par1 where
10211017
-- Direct occurrences of the last type parameter are decoded with the
10221018
-- function passed in as an argument:
10231019
gParseJSON _opts (From1Args _ pj _) = fmap Par1 . pj
10241020
{-# INLINE gParseJSON #-}
10251021

1026-
instance GOmitFromJSON One Par1 where
1027-
gOmittedField (From1Args o _ _) = fmap Par1 o
1028-
{-# INLINE gOmittedField #-}
1029-
10301022
instance (FromJSON1 f) => GFromJSON One (Rec1 f) where
10311023
-- Recursive occurrences of the last type parameter are decoded using their
10321024
-- FromJSON1 instance:
10331025
gParseJSON _opts (From1Args o pj pjl) = fmap Rec1 . liftParseJSON o pj pjl
10341026
{-# INLINE gParseJSON #-}
10351027

1036-
instance FromJSON1 f => GOmitFromJSON One (Rec1 f) where
1037-
gOmittedField (From1Args o _ _) = fmap Rec1 $ liftOmittedField o
1038-
{-# INLINE gOmittedField #-}
1039-
10401028
instance (FromJSON1 f, GFromJSON One g) => GFromJSON One (f :.: g) where
10411029
-- If an occurrence of the last type parameter is nested inside two
10421030
-- composed types, it is decoded by using the outermost type's FromJSON1
@@ -1049,6 +1037,18 @@ instance (FromJSON1 f, GFromJSON One g) => GFromJSON One (f :.: g) where
10491037
in fmap Comp1 . liftParseJSON Nothing gpj (listParser gpj)
10501038
{-# INLINE gParseJSON #-}
10511039

1040+
instance FromJSON a => GOmitFromJSON arity (K1 i a) where
1041+
gOmittedField _ = fmap K1 omittedField
1042+
{-# INLINE gOmittedField #-}
1043+
1044+
instance GOmitFromJSON One Par1 where
1045+
gOmittedField (From1Args o _ _) = fmap Par1 o
1046+
{-# INLINE gOmittedField #-}
1047+
1048+
instance FromJSON1 f => GOmitFromJSON One (Rec1 f) where
1049+
gOmittedField (From1Args o _ _) = fmap Rec1 $ liftOmittedField o
1050+
{-# INLINE gOmittedField #-}
1051+
10521052
instance (FromJSON1 f, GOmitFromJSON One g) => GOmitFromJSON One (f :.: g) where
10531053
gOmittedField = fmap Comp1 . liftOmittedField . gOmittedField
10541054
{-# INLINE gOmittedField #-}

0 commit comments

Comments
 (0)
Please sign in to comment.