@@ -631,9 +631,19 @@ class RecJsonParse (lts :: [*]) where
631instance RecJsonParse '[] where
631instance RecJsonParse '[] where
632 recJsonParse _ initSize _ = pure (ForallST (unsafeRNil initSize))
632 recJsonParse _ initSize _ = pure (ForallST (unsafeRNil initSize))
634+class FromJSON a => ParseField a where
635+ parseField :: Object -> T.Text -> Parser a
637+instance FromJSON a => ParseField a where
640+instance {-# OVERLAPS #-} FromJSON a => ParseField (Maybe a) where
635 ( KnownSymbol l,
644 ( KnownSymbol l,
636 FromJSON t,
645 FromJSON t,
637 RecJsonParse lts,
647 RecJsonParse lts,
638 RecSize lts ~ s,
648 RecSize lts ~ s,
639 KnownNat s,
649 KnownNat s,
@@ -645,7 +655,7 @@ instance
645 let lbl :: FldProxy l
655 let lbl :: FldProxy l
646 lbl = FldProxy
656 lbl = FldProxy
647 rest <- recJsonParse options initSize obj
657 rest <- recJsonParse options initSize obj
648− (v :: t) <- obj .: T.pack (fieldTransform options (symbolVal lbl))
658+ (v :: t) <- obj `parseField` T.pack (fieldTransform options (symbolVal lbl))
649 pure $ ForallST (unsafeRCons (lbl := v) =<< unForallST rest)
659 pure $ ForallST (unsafeRCons (lbl := v) =<< unForallST rest)
651-- | Machinery for NFData
661-- | Machinery for NFData