on master help sign in
Refactor (notFound . unpack) as notFound
commitccb35ece1c25f85b7761a324c70f05c971ac4ca0 authorlyxia <li-yao.xia@ens.fr> dateFri 20 May 2016, 17:28 (10 years ago) parentcdf6db1
1 file changed+6−6
Data/Aeson/Types/Generic.hs+6−6
Data/Aeson/Types/Generic.hs+6−6
@@ -544,7 +544,7 @@ instance ( FromPair (a :+: b)
544544
545545parseAllNullarySum :: SumFromString f => Options -> Value -> Parser (f a)
546546parseAllNullarySum opts = withText "Text" $ \key ->
547− maybe (notFound $ unpack key) return $
547+ maybe (notFound key) return $
548548 parseSumFromString opts key
549549
550550class SumFromString f where
@@ -571,13 +571,13 @@ parseNonAllNullarySum opts =
571571 TaggedObject{..} ->
572572 withObject "Object" $ \obj -> do
573573 tag <- obj .: pack tagFieldName
574− fromMaybe (notFound $ unpack tag) $
574+ fromMaybe (notFound tag) $
575575 parseFromTaggedObject opts contentsFieldName obj tag
576576
577577 ObjectWithSingleField ->
578578 withObject "Object" $ \obj ->
579579 case H.toList obj of
580− [pair@(tag, _)] -> fromMaybe (notFound $ unpack tag) $
580+ [pair@(tag, _)] -> fromMaybe (notFound tag) $
581581 parsePair opts pair
582582 _ -> fail "Object doesn't have a single field"
583583
@@ -585,7 +585,7 @@ parseNonAllNullarySum opts =
585585 withArray "Array" $ \arr ->
586586 if V.length arr == 2
587587 then case V.unsafeIndex arr 0 of
588− String tag -> fromMaybe (notFound $ unpack tag) $
588+ String tag -> fromMaybe (notFound tag) $
589589 parsePair opts (tag, V.unsafeIndex arr 1)
590590 _ -> fail "First element is not a String"
591591 else fail "Array doesn't have 2 elements"
@@ -791,6 +791,6 @@ newtype Tagged2 (s :: * -> *) b = Tagged2 {unTagged2 :: b}
791791
792792--------------------------------------------------------------------------------
793793
794−notFound :: String -> Parser a
795−notFound key = fail $ "The key \"" ++ key ++ "\" was not found"
794+notFound :: Text -> Parser a
795+notFound key = fail $ "The key \"" ++ unpack key ++ "\" was not found"
796796{-# INLINE notFound #-}