@@ -72,7 +72,7 @@ import Data.Ratio (Ratio, (%), numerator, denominator)
7272import Data.Text (Text, pack, unpack)
7373import Data.Time (UTCTime, ZonedTime(..), TimeZone(..))
7474import Data.Time.Format (FormatTime, formatTime, parseTime)
75−import Data.Traversable (traverse)
75+import Data.Traversable as Tr (sequence, traverse)
7676import Data.Vector (Vector)
7777import Data.Word (Word, Word8, Word16, Word32, Word64)
7878import Foreign.Storable (Storable)
@@ -101,6 +101,9 @@ import Data.Time.Format (defaultTimeLocale, dateTimeFmt)
101101import System.Locale (defaultTimeLocale, dateTimeFmt)
102102#endif
103103
104+parseIndexedJSON :: FromJSON a => Int -> Value -> Parser a
105+parseIndexedJSON idx value = parseJSON value <?> Index idx
106+
104107instance (ToJSON a) => ToJSON (Identity a) where
105108 toJSON (Identity a) = toJSON a
106109 {-# INLINE toJSON #-}
@@ -420,7 +423,7 @@ instance (ToJSON a) => ToJSON [a] where
420423 where commas = P.foldr (\v vs -> B.char7 ',' <> toEncoding v <> vs) mempty
421424
422425instance (FromJSON a) => FromJSON [a] where
423− parseJSON = withArray "[a]" $ mapM parseJSON . V.toList
426+ parseJSON = withArray "[a]" $ Tr.sequence . zipWith parseIndexedJSON [0..] . V.toList
424427 {-# INLINE parseJSON #-}
425428
426429instance (Foldable t, ToJSON a) => ToJSON (t a) where
@@ -448,7 +451,7 @@ encodeVector xs
448451 where go v b = B.char7 ',' <> toEncoding v <> b
449452
450453instance (FromJSON a) => FromJSON (Vector a) where
451− parseJSON = withArray "Vector a" $ V.mapM parseJSON
454+ parseJSON = withArray "Vector a" $ V.mapM (uncurry parseIndexedJSON) . V.indexed
452455 {-# INLINE parseJSON #-}
453456
454457vectorToJSON :: (VG.Vector v a, ToJSON a) => v a -> Value
@@ -456,7 +459,7 @@ vectorToJSON = Array . V.map toJSON . V.convert
456459{-# INLINE vectorToJSON #-}
457460
458461vectorParseJSON :: (FromJSON a, VG.Vector w a) => String -> Value -> Parser (w a)
459−vectorParseJSON s = withArray s $ fmap V.convert . V.mapM parseJSON
462+vectorParseJSON s = withArray s $ fmap V.convert . V.mapM (uncurry parseIndexedJSON) . V.indexed
460463{-# INLINE vectorParseJSON #-}
461464
462465instance (Storable a, ToJSON a) => ToJSON (VS.Vector a) where
@@ -563,7 +566,7 @@ encodePair k v = toEncoding k <> B.char7 ':' <> toEncoding v
563566
564567instance (FromJSON v) => FromJSON (M.Map Text v) where
565568 parseJSON = withObject "Map Text a" $
566− fmap (H.foldrWithKey M.insert M.empty) . traverse parseJSON
569+ fmap (H.foldrWithKey M.insert M.empty) . H.traverseWithKey (\k v -> parseJSON v <?> Key k)
567570
568571instance (ToJSON v) => ToJSON (M.Map LT.Text v) where
569572 toJSON = Object . mapHashKeyVal LT.toStrict toJSON
@@ -588,7 +591,7 @@ instance (ToJSON v) => ToJSON (H.HashMap Text v) where
588591 toEncoding = encodeWithKey H.foldrWithKey
589592
590593instance (FromJSON v) => FromJSON (H.HashMap Text v) where
591− parseJSON = withObject "HashMap Text a" $ traverse parseJSON
594+ parseJSON = withObject "HashMap Text a" $ H.traverseWithKey (\k v -> parseJSON v <?> Key k)
592595
593596instance (ToJSON v) => ToJSON (H.HashMap LT.Text v) where
594597 toJSON = Object . mapKeyVal LT.toStrict toJSON
@@ -711,6 +714,9 @@ instance FromJSON UTCTime where
711714 _ -> fail "could not parse ISO-8601 date"
712715 {-# INLINE parseJSON #-}
713716
717+parseJSONElemAtIndex :: FromJSON a => Int -> Vector Value -> Parser a
718+parseJSONElemAtIndex idx ary = parseJSON (V.unsafeIndex ary idx) <?> Index idx
719+
714720instance (ToJSON a, ToJSON b) => ToJSON (a,b) where
715721 toJSON (a,b) = Array $ V.create $ do
716722 mv <- VM.unsafeNew 2
@@ -727,8 +733,8 @@ instance (FromJSON a, FromJSON b) => FromJSON (a,b) where
727733 parseJSON = withArray "(a,b)" $ \ab ->
728734 let n = V.length ab
729735 in if n == 2
730− then (,) <$> parseJSON (V.unsafeIndex ab 0)
731− <*> parseJSON (V.unsafeIndex ab 1)
736+ then (,) <$> parseJSONElemAtIndex 0 ab
737+ <*> parseJSONElemAtIndex 1 ab
732738 else fail $ "cannot unpack array of length " ++
733739 show n ++ " into a pair"
734740 {-# INLINE parseJSON #-}
@@ -751,9 +757,9 @@ instance (FromJSON a, FromJSON b, FromJSON c) => FromJSON (a,b,c) where
751757 parseJSON = withArray "(a,b,c)" $ \abc ->
752758 let n = V.length abc
753759 in if n == 3
754− then (,,) <$> parseJSON (V.unsafeIndex abc 0)
755− <*> parseJSON (V.unsafeIndex abc 1)
756− <*> parseJSON (V.unsafeIndex abc 2)
760+ then (,,) <$> parseJSONElemAtIndex 0 abc
761+ <*> parseJSONElemAtIndex 1 abc
762+ <*> parseJSONElemAtIndex 2 abc
757763 else fail $ "cannot unpack array of length " ++
758764 show n ++ " into a 3-tuple"
759765 {-# INLINE parseJSON #-}
@@ -779,10 +785,10 @@ instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d) =>
779785 parseJSON = withArray "(a,b,c,d)" $ \abcd ->
780786 let n = V.length abcd
781787 in if n == 4
782− then (,,,) <$> parseJSON (V.unsafeIndex abcd 0)
783− <*> parseJSON (V.unsafeIndex abcd 1)
784− <*> parseJSON (V.unsafeIndex abcd 2)
785− <*> parseJSON (V.unsafeIndex abcd 3)
788+ then (,,,) <$> parseJSONElemAtIndex 0 abcd
789+ <*> parseJSONElemAtIndex 1 abcd
790+ <*> parseJSONElemAtIndex 2 abcd
791+ <*> parseJSONElemAtIndex 3 abcd
786792 else fail $ "cannot unpack array of length " ++
787793 show n ++ " into a 4-tuple"
788794 {-# INLINE parseJSON #-}
@@ -811,11 +817,11 @@ instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e) =>
811817 parseJSON = withArray "(a,b,c,d,e)" $ \abcde ->
812818 let n = V.length abcde
813819 in if n == 5
814− then (,,,,) <$> parseJSON (V.unsafeIndex abcde 0)
815− <*> parseJSON (V.unsafeIndex abcde 1)
816− <*> parseJSON (V.unsafeIndex abcde 2)
817− <*> parseJSON (V.unsafeIndex abcde 3)
818− <*> parseJSON (V.unsafeIndex abcde 4)
820+ then (,,,,) <$> parseJSONElemAtIndex 0 abcde
821+ <*> parseJSONElemAtIndex 1 abcde
822+ <*> parseJSONElemAtIndex 2 abcde
823+ <*> parseJSONElemAtIndex 3 abcde
824+ <*> parseJSONElemAtIndex 4 abcde
819825 else fail $ "cannot unpack array of length " ++
820826 show n ++ " into a 5-tuple"
821827 {-# INLINE parseJSON #-}
@@ -846,12 +852,12 @@ instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
846852 parseJSON = withArray "(a,b,c,d,e,f)" $ \abcdef ->
847853 let n = V.length abcdef
848854 in if n == 6
849− then (,,,,,) <$> parseJSON (V.unsafeIndex abcdef 0)
850− <*> parseJSON (V.unsafeIndex abcdef 1)
851− <*> parseJSON (V.unsafeIndex abcdef 2)
852− <*> parseJSON (V.unsafeIndex abcdef 3)
853− <*> parseJSON (V.unsafeIndex abcdef 4)
854− <*> parseJSON (V.unsafeIndex abcdef 5)
855+ then (,,,,,) <$> parseJSONElemAtIndex 0 abcdef
856+ <*> parseJSONElemAtIndex 1 abcdef
857+ <*> parseJSONElemAtIndex 2 abcdef
858+ <*> parseJSONElemAtIndex 3 abcdef
859+ <*> parseJSONElemAtIndex 4 abcdef
860+ <*> parseJSONElemAtIndex 5 abcdef
855861 else fail $ "cannot unpack array of length " ++
856862 show n ++ " into a 6-tuple"
857863 {-# INLINE parseJSON #-}
@@ -884,13 +890,13 @@ instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
884890 parseJSON = withArray "(a,b,c,d,e,f,g)" $ \abcdefg ->
885891 let n = V.length abcdefg
886892 in if n == 7
887− then (,,,,,,) <$> parseJSON (V.unsafeIndex abcdefg 0)
888− <*> parseJSON (V.unsafeIndex abcdefg 1)
889− <*> parseJSON (V.unsafeIndex abcdefg 2)
890− <*> parseJSON (V.unsafeIndex abcdefg 3)
891− <*> parseJSON (V.unsafeIndex abcdefg 4)
892− <*> parseJSON (V.unsafeIndex abcdefg 5)
893− <*> parseJSON (V.unsafeIndex abcdefg 6)
893+ then (,,,,,,) <$> parseJSONElemAtIndex 0 abcdefg
894+ <*> parseJSONElemAtIndex 1 abcdefg
895+ <*> parseJSONElemAtIndex 2 abcdefg
896+ <*> parseJSONElemAtIndex 3 abcdefg
897+ <*> parseJSONElemAtIndex 4 abcdefg
898+ <*> parseJSONElemAtIndex 5 abcdefg
899+ <*> parseJSONElemAtIndex 6 abcdefg
894900 else fail $ "cannot unpack array of length " ++
895901 show n ++ " into a 7-tuple"
896902 {-# INLINE parseJSON #-}
@@ -929,14 +935,14 @@ instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
929935 then fail $ "cannot unpack array of length " ++
930936 show n ++ " into an 8-tuple"
931937 else (,,,,,,,)
932− <$> parseJSON (V.unsafeIndex ary 0)
933− <*> parseJSON (V.unsafeIndex ary 1)
934− <*> parseJSON (V.unsafeIndex ary 2)
935− <*> parseJSON (V.unsafeIndex ary 3)
936− <*> parseJSON (V.unsafeIndex ary 4)
937− <*> parseJSON (V.unsafeIndex ary 5)
938− <*> parseJSON (V.unsafeIndex ary 6)
939− <*> parseJSON (V.unsafeIndex ary 7)
938+ <$> parseJSONElemAtIndex 0 ary
939+ <*> parseJSONElemAtIndex 1 ary
940+ <*> parseJSONElemAtIndex 2 ary
941+ <*> parseJSONElemAtIndex 3 ary
942+ <*> parseJSONElemAtIndex 4 ary
943+ <*> parseJSONElemAtIndex 5 ary
944+ <*> parseJSONElemAtIndex 6 ary
945+ <*> parseJSONElemAtIndex 7 ary
940946 {-# INLINE parseJSON #-}
941947
942948instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
@@ -975,15 +981,15 @@ instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
975981 then fail $ "cannot unpack array of length " ++
976982 show n ++ " into a 9-tuple"
977983 else (,,,,,,,,)
978− <$> parseJSON (V.unsafeIndex ary 0)
979− <*> parseJSON (V.unsafeIndex ary 1)
980− <*> parseJSON (V.unsafeIndex ary 2)
981− <*> parseJSON (V.unsafeIndex ary 3)
982− <*> parseJSON (V.unsafeIndex ary 4)
983− <*> parseJSON (V.unsafeIndex ary 5)
984− <*> parseJSON (V.unsafeIndex ary 6)
985− <*> parseJSON (V.unsafeIndex ary 7)
986− <*> parseJSON (V.unsafeIndex ary 8)
984+ <$> parseJSONElemAtIndex 0 ary
985+ <*> parseJSONElemAtIndex 1 ary
986+ <*> parseJSONElemAtIndex 2 ary
987+ <*> parseJSONElemAtIndex 3 ary
988+ <*> parseJSONElemAtIndex 4 ary
989+ <*> parseJSONElemAtIndex 5 ary
990+ <*> parseJSONElemAtIndex 6 ary
991+ <*> parseJSONElemAtIndex 7 ary
992+ <*> parseJSONElemAtIndex 8 ary
987993 {-# INLINE parseJSON #-}
988994
989995instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
@@ -1025,16 +1031,16 @@ instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
10251031 then fail $ "cannot unpack array of length " ++
10261032 show n ++ " into a 10-tuple"
10271033 else (,,,,,,,,,)
1028− <$> parseJSON (V.unsafeIndex ary 0)
1029− <*> parseJSON (V.unsafeIndex ary 1)
1030− <*> parseJSON (V.unsafeIndex ary 2)
1031− <*> parseJSON (V.unsafeIndex ary 3)
1032− <*> parseJSON (V.unsafeIndex ary 4)
1033− <*> parseJSON (V.unsafeIndex ary 5)
1034− <*> parseJSON (V.unsafeIndex ary 6)
1035− <*> parseJSON (V.unsafeIndex ary 7)
1036− <*> parseJSON (V.unsafeIndex ary 8)
1037− <*> parseJSON (V.unsafeIndex ary 9)
1034+ <$> parseJSONElemAtIndex 0 ary
1035+ <*> parseJSONElemAtIndex 1 ary
1036+ <*> parseJSONElemAtIndex 2 ary
1037+ <*> parseJSONElemAtIndex 3 ary
1038+ <*> parseJSONElemAtIndex 4 ary
1039+ <*> parseJSONElemAtIndex 5 ary
1040+ <*> parseJSONElemAtIndex 6 ary
1041+ <*> parseJSONElemAtIndex 7 ary
1042+ <*> parseJSONElemAtIndex 8 ary
1043+ <*> parseJSONElemAtIndex 9 ary
10381044 {-# INLINE parseJSON #-}
10391045
10401046instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
@@ -1079,17 +1085,17 @@ instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
10791085 then fail $ "cannot unpack array of length " ++
10801086 show n ++ " into an 11-tuple"
10811087 else (,,,,,,,,,,)
1082− <$> parseJSON (V.unsafeIndex ary 0)
1083− <*> parseJSON (V.unsafeIndex ary 1)
1084− <*> parseJSON (V.unsafeIndex ary 2)
1085− <*> parseJSON (V.unsafeIndex ary 3)
1086− <*> parseJSON (V.unsafeIndex ary 4)
1087− <*> parseJSON (V.unsafeIndex ary 5)
1088− <*> parseJSON (V.unsafeIndex ary 6)
1089− <*> parseJSON (V.unsafeIndex ary 7)
1090− <*> parseJSON (V.unsafeIndex ary 8)
1091− <*> parseJSON (V.unsafeIndex ary 9)
1092− <*> parseJSON (V.unsafeIndex ary 10)
1088+ <$> parseJSONElemAtIndex 0 ary
1089+ <*> parseJSONElemAtIndex 1 ary
1090+ <*> parseJSONElemAtIndex 2 ary
1091+ <*> parseJSONElemAtIndex 3 ary
1092+ <*> parseJSONElemAtIndex 4 ary
1093+ <*> parseJSONElemAtIndex 5 ary
1094+ <*> parseJSONElemAtIndex 6 ary
1095+ <*> parseJSONElemAtIndex 7 ary
1096+ <*> parseJSONElemAtIndex 8 ary
1097+ <*> parseJSONElemAtIndex 9 ary
1098+ <*> parseJSONElemAtIndex 10 ary
10931099 {-# INLINE parseJSON #-}
10941100
10951101instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
@@ -1136,18 +1142,18 @@ instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
11361142 then fail $ "cannot unpack array of length " ++
11371143 show n ++ " into a 12-tuple"
11381144 else (,,,,,,,,,,,)
1139− <$> parseJSON (V.unsafeIndex ary 0)
1140− <*> parseJSON (V.unsafeIndex ary 1)
1141− <*> parseJSON (V.unsafeIndex ary 2)
1142− <*> parseJSON (V.unsafeIndex ary 3)
1143− <*> parseJSON (V.unsafeIndex ary 4)
1144− <*> parseJSON (V.unsafeIndex ary 5)
1145− <*> parseJSON (V.unsafeIndex ary 6)
1146− <*> parseJSON (V.unsafeIndex ary 7)
1147− <*> parseJSON (V.unsafeIndex ary 8)
1148− <*> parseJSON (V.unsafeIndex ary 9)
1149− <*> parseJSON (V.unsafeIndex ary 10)
1150− <*> parseJSON (V.unsafeIndex ary 11)
1145+ <$> parseJSONElemAtIndex 0 ary
1146+ <*> parseJSONElemAtIndex 1 ary
1147+ <*> parseJSONElemAtIndex 2 ary
1148+ <*> parseJSONElemAtIndex 3 ary
1149+ <*> parseJSONElemAtIndex 4 ary
1150+ <*> parseJSONElemAtIndex 5 ary
1151+ <*> parseJSONElemAtIndex 6 ary
1152+ <*> parseJSONElemAtIndex 7 ary
1153+ <*> parseJSONElemAtIndex 8 ary
1154+ <*> parseJSONElemAtIndex 9 ary
1155+ <*> parseJSONElemAtIndex 10 ary
1156+ <*> parseJSONElemAtIndex 11 ary
11511157 {-# INLINE parseJSON #-}
11521158
11531159instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
@@ -1197,19 +1203,19 @@ instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
11971203 then fail $ "cannot unpack array of length " ++
11981204 show n ++ " into a 13-tuple"
11991205 else (,,,,,,,,,,,,)
1200− <$> parseJSON (V.unsafeIndex ary 0)
1201− <*> parseJSON (V.unsafeIndex ary 1)
1202− <*> parseJSON (V.unsafeIndex ary 2)
1203− <*> parseJSON (V.unsafeIndex ary 3)
1204− <*> parseJSON (V.unsafeIndex ary 4)
1205− <*> parseJSON (V.unsafeIndex ary 5)
1206− <*> parseJSON (V.unsafeIndex ary 6)
1207− <*> parseJSON (V.unsafeIndex ary 7)
1208− <*> parseJSON (V.unsafeIndex ary 8)
1209− <*> parseJSON (V.unsafeIndex ary 9)
1210− <*> parseJSON (V.unsafeIndex ary 10)
1211− <*> parseJSON (V.unsafeIndex ary 11)
1212− <*> parseJSON (V.unsafeIndex ary 12)
1206+ <$> parseJSONElemAtIndex 0 ary
1207+ <*> parseJSONElemAtIndex 1 ary
1208+ <*> parseJSONElemAtIndex 2 ary
1209+ <*> parseJSONElemAtIndex 3 ary
1210+ <*> parseJSONElemAtIndex 4 ary
1211+ <*> parseJSONElemAtIndex 5 ary
1212+ <*> parseJSONElemAtIndex 6 ary
1213+ <*> parseJSONElemAtIndex 7 ary
1214+ <*> parseJSONElemAtIndex 8 ary
1215+ <*> parseJSONElemAtIndex 9 ary
1216+ <*> parseJSONElemAtIndex 10 ary
1217+ <*> parseJSONElemAtIndex 11 ary
1218+ <*> parseJSONElemAtIndex 12 ary
12131219 {-# INLINE parseJSON #-}
12141220
12151221instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
@@ -1261,20 +1267,20 @@ instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
12611267 then fail $ "cannot unpack array of length " ++
12621268 show n ++ " into a 14-tuple"
12631269 else (,,,,,,,,,,,,,)
1264− <$> parseJSON (V.unsafeIndex ary 0)
1265− <*> parseJSON (V.unsafeIndex ary 1)
1266− <*> parseJSON (V.unsafeIndex ary 2)
1267− <*> parseJSON (V.unsafeIndex ary 3)
1268− <*> parseJSON (V.unsafeIndex ary 4)
1269− <*> parseJSON (V.unsafeIndex ary 5)
1270− <*> parseJSON (V.unsafeIndex ary 6)
1271− <*> parseJSON (V.unsafeIndex ary 7)
1272− <*> parseJSON (V.unsafeIndex ary 8)
1273− <*> parseJSON (V.unsafeIndex ary 9)
1274− <*> parseJSON (V.unsafeIndex ary 10)
1275− <*> parseJSON (V.unsafeIndex ary 11)
1276− <*> parseJSON (V.unsafeIndex ary 12)
1277− <*> parseJSON (V.unsafeIndex ary 13)
1270+ <$> parseJSONElemAtIndex 0 ary
1271+ <*> parseJSONElemAtIndex 1 ary
1272+ <*> parseJSONElemAtIndex 2 ary
1273+ <*> parseJSONElemAtIndex 3 ary
1274+ <*> parseJSONElemAtIndex 4 ary
1275+ <*> parseJSONElemAtIndex 5 ary
1276+ <*> parseJSONElemAtIndex 6 ary
1277+ <*> parseJSONElemAtIndex 7 ary
1278+ <*> parseJSONElemAtIndex 8 ary
1279+ <*> parseJSONElemAtIndex 9 ary
1280+ <*> parseJSONElemAtIndex 10 ary
1281+ <*> parseJSONElemAtIndex 11 ary
1282+ <*> parseJSONElemAtIndex 12 ary
1283+ <*> parseJSONElemAtIndex 13 ary
12781284 {-# INLINE parseJSON #-}
12791285
12801286instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
@@ -1328,21 +1334,21 @@ instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
13281334 then fail $ "cannot unpack array of length " ++
13291335 show n ++ " into a 15-tuple"
13301336 else (,,,,,,,,,,,,,,)
1331− <$> parseJSON (V.unsafeIndex ary 0)
1332− <*> parseJSON (V.unsafeIndex ary 1)
1333− <*> parseJSON (V.unsafeIndex ary 2)
1334− <*> parseJSON (V.unsafeIndex ary 3)
1335− <*> parseJSON (V.unsafeIndex ary 4)
1336− <*> parseJSON (V.unsafeIndex ary 5)
1337− <*> parseJSON (V.unsafeIndex ary 6)
1338− <*> parseJSON (V.unsafeIndex ary 7)
1339− <*> parseJSON (V.unsafeIndex ary 8)
1340− <*> parseJSON (V.unsafeIndex ary 9)
1341− <*> parseJSON (V.unsafeIndex ary 10)
1342− <*> parseJSON (V.unsafeIndex ary 11)
1343− <*> parseJSON (V.unsafeIndex ary 12)
1344− <*> parseJSON (V.unsafeIndex ary 13)
1345− <*> parseJSON (V.unsafeIndex ary 14)
1337+ <$> parseJSONElemAtIndex 0 ary
1338+ <*> parseJSONElemAtIndex 1 ary
1339+ <*> parseJSONElemAtIndex 2 ary
1340+ <*> parseJSONElemAtIndex 3 ary
1341+ <*> parseJSONElemAtIndex 4 ary
1342+ <*> parseJSONElemAtIndex 5 ary
1343+ <*> parseJSONElemAtIndex 6 ary
1344+ <*> parseJSONElemAtIndex 7 ary
1345+ <*> parseJSONElemAtIndex 8 ary
1346+ <*> parseJSONElemAtIndex 9 ary
1347+ <*> parseJSONElemAtIndex 10 ary
1348+ <*> parseJSONElemAtIndex 11 ary
1349+ <*> parseJSONElemAtIndex 12 ary
1350+ <*> parseJSONElemAtIndex 13 ary
1351+ <*> parseJSONElemAtIndex 14 ary
13461352 {-# INLINE parseJSON #-}
13471353
13481354instance ToJSON a => ToJSON (Dual a) where
@@ -1437,7 +1443,7 @@ fromJSON = parse parseJSON
14371443(.:) :: (FromJSON a) => Object -> Text -> Parser a
14381444obj .: key = case H.lookup key obj of
14391445 Nothing -> fail $ "key " ++ show key ++ " not present"
1440− Just v -> parseJSON v
1446+ Just v -> parseJSON v <?> Key key
14411447{-# INLINE (.:) #-}
14421448
14431449-- | Retrieve the value associated with the given key of an 'Object'.
@@ -1450,7 +1456,7 @@ obj .: key = case H.lookup key obj of
14501456(.:?) :: (FromJSON a) => Object -> Text -> Parser (Maybe a)
14511457obj .:? key = case H.lookup key obj of
14521458 Nothing -> pure Nothing
1453− Just v -> parseJSON v
1459+ Just v -> parseJSON v <?> Key key
14541460{-# INLINE (.:?) #-}
14551461
14561462-- | Helper for use in combination with '.:?' to provide default