Skip to content

Commit

Permalink
Merge pull request #423 from phadej/error-in-map
Browse files Browse the repository at this point in the history
Tell which key failed to parse in maps
  • Loading branch information
bergmark committed Jun 13, 2016
2 parents 737ed5c + 6c60aff commit 6a983c6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Data/Aeson/Types/FromJSON.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ instance (FromJSONKey k, Ord k) => FromJSON1 (M.Map k) where
FromJSONKeyText f -> withObject "Map k v" $
fmap (H.foldrWithKey (M.insert . f) M.empty) . H.traverseWithKey (\k v -> p v <?> Key k)
FromJSONKeyTextParser f -> withObject "Map k v" $
H.foldrWithKey (\k v m -> M.insert <$> f k <*> (p v <?> Key k) <*> m) (pure M.empty)
H.foldrWithKey (\k v m -> M.insert <$> f k <?> Key k <*> p v <?> Key k <*> m) (pure M.empty)
FromJSONKeyValue f -> withArray "Map k v" $ \arr ->
M.fromList <$> (Tr.sequence .
zipWith (parseIndexedJSONPair f p) [0..] . V.toList $ arr)
Expand Down Expand Up @@ -1368,7 +1368,7 @@ instance (FromJSONKey k, Eq k, Hashable k) => FromJSON1 (H.HashMap k) where
FromJSONKeyText f -> withObject "HashMap k v" $
fmap (mapKey f) . H.traverseWithKey (\k v -> p v <?> Key k)
FromJSONKeyTextParser f -> withObject "HashMap k v" $
H.foldrWithKey (\k v m -> H.insert <$> f k <*> (p v <?> Key k) <*> m) (pure H.empty)
H.foldrWithKey (\k v m -> H.insert <$> f k <?> Key k <*> p v <?> Key k <*> m) (pure H.empty)
FromJSONKeyValue f -> withArray "Map k v" $ \arr ->
H.fromList <$> (Tr.sequence .
zipWith (parseIndexedJSONPair f p) [0..] . V.toList $ arr)
Expand Down

0 comments on commit 6a983c6

Please sign in to comment.