@@ -555,7 +555,7 @@ instance ( FromPair (a :+: b)
556parseAllNullarySum :: SumFromString f => Options -> Value -> Parser (f a)
556parseAllNullarySum :: SumFromString f => Options -> Value -> Parser (f a)
557parseAllNullarySum opts = withText "Text" $ \key ->
557parseAllNullarySum opts = withText "Text" $ \key ->
558− maybe (notFound $ unpack key) return $
558+ maybe (notFound key) return $
559 parseSumFromString opts key
559 parseSumFromString opts key
561class SumFromString f where
561class SumFromString f where
@@ -582,13 +582,13 @@ parseNonAllNullarySum opts =
582 TaggedObject{..} ->
582 TaggedObject{..} ->
583 withObject "Object" $ \obj -> do
583 withObject "Object" $ \obj -> do
584 tag <- obj .: pack tagFieldName
584 tag <- obj .: pack tagFieldName
585− fromMaybe (notFound $ unpack tag) $
585+ fromMaybe (notFound tag) $
586 parseFromTaggedObject opts contentsFieldName obj tag
586 parseFromTaggedObject opts contentsFieldName obj tag
588 ObjectWithSingleField ->
588 ObjectWithSingleField ->
589 withObject "Object" $ \obj ->
589 withObject "Object" $ \obj ->
590 case H.toList obj of
590 case H.toList obj of
591− [pair@(tag, _)] -> fromMaybe (notFound $ unpack tag) $
591+ [pair@(tag, _)] -> fromMaybe (notFound tag) $
592 parsePair opts pair
592 parsePair opts pair
593 _ -> fail "Object doesn't have a single field"
593 _ -> fail "Object doesn't have a single field"
@@ -596,7 +596,7 @@ parseNonAllNullarySum opts =
596 withArray "Array" $ \arr ->
596 withArray "Array" $ \arr ->
597 if V.length arr == 2
597 if V.length arr == 2
598 then case V.unsafeIndex arr 0 of
598 then case V.unsafeIndex arr 0 of
599− String tag -> fromMaybe (notFound $ unpack tag) $
599+ String tag -> fromMaybe (notFound tag) $
600 parsePair opts (tag, V.unsafeIndex arr 1)
600 parsePair opts (tag, V.unsafeIndex arr 1)
601 _ -> fail "First element is not a String"
601 _ -> fail "First element is not a String"
602 else fail "Array doesn't have 2 elements"
602 else fail "Array doesn't have 2 elements"
@@ -690,12 +690,11 @@ instance (FromRecord a, FromRecord b) => FromRecord (a :*: b) where
690 <*> parseRecord opts Nothing obj
690 <*> parseRecord opts Nothing obj
692instance (Selector s, GFromJSON a) => FromRecord (S1 s a) where
692instance (Selector s, GFromJSON a) => FromRecord (S1 s a) where
693− parseRecord opts (Just lab) = maybe (notFound $ unpack lab)
693+ parseRecord opts lab = (<?> Key label) . gParseJSON opts <=< (.: label)
694− (gParseJSON opts) . H.lookup lab
695− parseRecord opts Nothing = maybe (notFound label)
696− (gParseJSON opts) . H.lookup (pack label)
695+ label = fromMaybe defLabel lab
696+ defLabel = pack . fieldLabelModifier opts $
698− label = fieldLabelModifier opts $ selName (undefined :: t s a p)
697+ selName (undefined :: t s a p)
700instance OVERLAPPING_ (Selector s, FromJSON a) =>
699instance OVERLAPPING_ (Selector s, FromJSON a) =>
701 FromRecord (S1 s (K1 i (Maybe a))) where
700 FromRecord (S1 s (K1 i (Maybe a))) where
@@ -803,6 +802,6 @@ newtype Tagged2 (s :: * -> *) b = Tagged2 {unTagged2 :: b}
804--------------------------------------------------------------------------------
803--------------------------------------------------------------------------------
806−notFound :: String -> Parser a
805+notFound :: Text -> Parser a
807−notFound key = fail $ "The key \"" ++ key ++ "\" was not found"
806+notFound key = fail $ "The key \"" ++ unpack key ++ "\" was not found"
808{-# INLINE notFound #-}
807{-# INLINE notFound #-}