Commits

basvandijk committed 8dd94d6

Treat the absence of a Maybe field as Nothing in the GHC Generics code

  • Participants
  • Parent commits 4e94672

Comments (0)

Files changed (1)

File Data/Aeson/Types/Generic.hs

           key = fieldNameModifier opts $ selName (undefined :: t s a p)
     {-# INLINE gParseRecord #-}
 
+instance (Selector s, FromJSON a) => GFromRecord (S1 s (K1 i (Maybe a))) where
+    gParseRecord opts obj = (M1 . K1) <$> obj .:? pack key
+        where
+          key = fieldNameModifier opts $
+                  selName (undefined :: t s (K1 i (Maybe a)) p)
+    {-# INLINE gParseRecord #-}
+
 --------------------------------------------------------------------------------
 
 class ProductSize f where