Skip to content

Commit 0f36b77

Browse files
committed
collect GOmitFromJSON instances
1 parent c56cfc1 commit 0f36b77

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/Data/Aeson/Types/FromJSON.hs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,30 +1016,18 @@ instance (FromJSON a) => GFromJSON arity (K1 i a) where
10161016
gParseJSON _opts _ = fmap K1 . parseJSON
10171017
{-# INLINE gParseJSON #-}
10181018

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

1029-
instance GOmitFromJSON One Par1 where
1030-
gOmittedField (From1Args o _ _) = fmap Par1 o
1031-
{-# INLINE gOmittedField #-}
1032-
10331025
instance (FromJSON1 f) => GFromJSON One (Rec1 f) where
10341026
-- Recursive occurrences of the last type parameter are decoded using their
10351027
-- FromJSON1 instance:
10361028
gParseJSON _opts (From1Args o pj pjl) = fmap Rec1 . liftParseJSON o pj pjl
10371029
{-# INLINE gParseJSON #-}
10381030

1039-
instance FromJSON1 f => GOmitFromJSON One (Rec1 f) where
1040-
gOmittedField (From1Args o _ _) = fmap Rec1 $ liftOmittedField o
1041-
{-# INLINE gOmittedField #-}
1042-
10431031
instance (FromJSON1 f, GFromJSON One g) => GFromJSON One (f :.: g) where
10441032
-- If an occurrence of the last type parameter is nested inside two
10451033
-- composed types, it is decoded by using the outermost type's FromJSON1
@@ -1052,6 +1040,18 @@ instance (FromJSON1 f, GFromJSON One g) => GFromJSON One (f :.: g) where
10521040
in fmap Comp1 . liftParseJSON Nothing gpj (listParser gpj)
10531041
{-# INLINE gParseJSON #-}
10541042

1043+
instance FromJSON a => GOmitFromJSON arity (K1 i a) where
1044+
gOmittedField _ = fmap K1 omittedField
1045+
{-# INLINE gOmittedField #-}
1046+
1047+
instance GOmitFromJSON One Par1 where
1048+
gOmittedField (From1Args o _ _) = fmap Par1 o
1049+
{-# INLINE gOmittedField #-}
1050+
1051+
instance FromJSON1 f => GOmitFromJSON One (Rec1 f) where
1052+
gOmittedField (From1Args o _ _) = fmap Rec1 $ liftOmittedField o
1053+
{-# INLINE gOmittedField #-}
1054+
10551055
instance (FromJSON1 f, GOmitFromJSON One g) => GOmitFromJSON One (f :.: g) where
10561056
gOmittedField = fmap Comp1 . liftOmittedField . gOmittedField
10571057
{-# INLINE gOmittedField #-}

0 commit comments

Comments
 (0)