@@ -72,7 +72,7 @@ import Data.Ratio (Ratio, (%), numerator, denominator)
72import Data.Text (Text, pack, unpack)
72import Data.Text (Text, pack, unpack)
73import Data.Time (UTCTime, ZonedTime(..), TimeZone(..))
73import Data.Time (UTCTime, ZonedTime(..), TimeZone(..))
74import Data.Time.Format (FormatTime, formatTime, parseTime)
74import Data.Time.Format (FormatTime, formatTime, parseTime)
75−import Data.Traversable (traverse)
75+import Data.Traversable as Tr (sequence, traverse)
76import Data.Vector (Vector)
76import Data.Vector (Vector)
77import Data.Word (Word, Word8, Word16, Word32, Word64)
77import Data.Word (Word, Word8, Word16, Word32, Word64)
78import Foreign.Storable (Storable)
78import Foreign.Storable (Storable)
@@ -101,6 +101,9 @@ import Data.Time.Format (defaultTimeLocale, dateTimeFmt)
101import System.Locale (defaultTimeLocale, dateTimeFmt)
101import System.Locale (defaultTimeLocale, dateTimeFmt)
104+parseIndexedJSON :: FromJSON a => Int -> Value -> Parser a
105+parseIndexedJSON idx value = parseJSON value <?> Index idx
104instance (ToJSON a) => ToJSON (Identity a) where
107instance (ToJSON a) => ToJSON (Identity a) where
105 toJSON (Identity a) = toJSON a
108 toJSON (Identity a) = toJSON a
106 {-# INLINE toJSON #-}
109 {-# INLINE toJSON #-}
@@ -420,7 +423,7 @@ instance (ToJSON a) => ToJSON [a] where
420 where commas = P.foldr (\v vs -> B.char7 ',' <> toEncoding v <> vs) mempty
423 where commas = P.foldr (\v vs -> B.char7 ',' <> toEncoding v <> vs) mempty
422instance (FromJSON a) => FromJSON [a] where
425instance (FromJSON a) => FromJSON [a] where
423− parseJSON = withArray "[a]" $ mapM parseJSON . V.toList
426+ parseJSON = withArray "[a]" $ Tr.sequence . zipWith parseIndexedJSON [0..] . V.toList
424 {-# INLINE parseJSON #-}
427 {-# INLINE parseJSON #-}
426instance (Foldable t, ToJSON a) => ToJSON (t a) where
429instance (Foldable t, ToJSON a) => ToJSON (t a) where
@@ -448,7 +451,7 @@ encodeVector xs
448 where go v b = B.char7 ',' <> toEncoding v <> b
451 where go v b = B.char7 ',' <> toEncoding v <> b
450instance (FromJSON a) => FromJSON (Vector a) where
453instance (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
452 {-# INLINE parseJSON #-}
455 {-# INLINE parseJSON #-}
454vectorToJSON :: (VG.Vector v a, ToJSON a) => v a -> Value
457vectorToJSON :: (VG.Vector v a, ToJSON a) => v a -> Value
@@ -456,7 +459,7 @@ vectorToJSON = Array . V.map toJSON . V.convert
456{-# INLINE vectorToJSON #-}
459{-# INLINE vectorToJSON #-}
458vectorParseJSON :: (FromJSON a, VG.Vector w a) => String -> Value -> Parser (w a)
461vectorParseJSON :: (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
460{-# INLINE vectorParseJSON #-}
463{-# INLINE vectorParseJSON #-}
462instance (Storable a, ToJSON a) => ToJSON (VS.Vector a) where
465instance (Storable a, ToJSON a) => ToJSON (VS.Vector a) where
@@ -563,7 +566,7 @@ encodePair k v = toEncoding k <> B.char7 ':' <> toEncoding v
564instance (FromJSON v) => FromJSON (M.Map Text v) where
567instance (FromJSON v) => FromJSON (M.Map Text v) where
565 parseJSON = withObject "Map Text a" $
568 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)
568instance (ToJSON v) => ToJSON (M.Map LT.Text v) where
571instance (ToJSON v) => ToJSON (M.Map LT.Text v) where
569 toJSON = Object . mapHashKeyVal LT.toStrict toJSON
572 toJSON = Object . mapHashKeyVal LT.toStrict toJSON
@@ -588,7 +591,7 @@ instance (ToJSON v) => ToJSON (H.HashMap Text v) where
588 toEncoding = encodeWithKey H.foldrWithKey
591 toEncoding = encodeWithKey H.foldrWithKey
590instance (FromJSON v) => FromJSON (H.HashMap Text v) where
593instance (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)
593instance (ToJSON v) => ToJSON (H.HashMap LT.Text v) where
596instance (ToJSON v) => ToJSON (H.HashMap LT.Text v) where
594 toJSON = Object . mapKeyVal LT.toStrict toJSON
597 toJSON = Object . mapKeyVal LT.toStrict toJSON
@@ -711,6 +714,9 @@ instance FromJSON UTCTime where
711 _ -> fail "could not parse ISO-8601 date"
714 _ -> fail "could not parse ISO-8601 date"
712 {-# INLINE parseJSON #-}
715 {-# INLINE parseJSON #-}
717+parseJSONElemAtIndex :: FromJSON a => Int -> Vector Value -> Parser a
718+parseJSONElemAtIndex idx ary = parseJSON (V.unsafeIndex ary idx) <?> Index idx
714instance (ToJSON a, ToJSON b) => ToJSON (a,b) where
720instance (ToJSON a, ToJSON b) => ToJSON (a,b) where
715 toJSON (a,b) = Array $ V.create $ do
721 toJSON (a,b) = Array $ V.create $ do
716 mv <- VM.unsafeNew 2
722 mv <- VM.unsafeNew 2
@@ -727,8 +733,8 @@ instance (FromJSON a, FromJSON b) => FromJSON (a,b) where
727 parseJSON = withArray "(a,b)" $ \ab ->
733 parseJSON = withArray "(a,b)" $ \ab ->
728 let n = V.length ab
734 let n = V.length ab
729 in if n == 2
735 in if n == 2
730− then (,) <$> parseJSON (V.unsafeIndex ab 0)
736+ then (,) <$> parseJSONElemAtIndex 0 ab
731− <*> parseJSON (V.unsafeIndex ab 1)
737+ <*> parseJSONElemAtIndex 1 ab
732 else fail $ "cannot unpack array of length " ++
738 else fail $ "cannot unpack array of length " ++
733 show n ++ " into a pair"
739 show n ++ " into a pair"
734 {-# INLINE parseJSON #-}
740 {-# INLINE parseJSON #-}
@@ -751,9 +757,9 @@ instance (FromJSON a, FromJSON b, FromJSON c) => FromJSON (a,b,c) where
751 parseJSON = withArray "(a,b,c)" $ \abc ->
757 parseJSON = withArray "(a,b,c)" $ \abc ->
752 let n = V.length abc
758 let n = V.length abc
753 in if n == 3
759 in if n == 3
754− then (,,) <$> parseJSON (V.unsafeIndex abc 0)
760+ then (,,) <$> parseJSONElemAtIndex 0 abc
755− <*> parseJSON (V.unsafeIndex abc 1)
761+ <*> parseJSONElemAtIndex 1 abc
756− <*> parseJSON (V.unsafeIndex abc 2)
762+ <*> parseJSONElemAtIndex 2 abc
757 else fail $ "cannot unpack array of length " ++
763 else fail $ "cannot unpack array of length " ++
758 show n ++ " into a 3-tuple"
764 show n ++ " into a 3-tuple"
759 {-# INLINE parseJSON #-}
765 {-# INLINE parseJSON #-}
@@ -779,10 +785,10 @@ instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d) =>
779 parseJSON = withArray "(a,b,c,d)" $ \abcd ->
785 parseJSON = withArray "(a,b,c,d)" $ \abcd ->
780 let n = V.length abcd
786 let n = V.length abcd
781 in if n == 4
787 in if n == 4
782− then (,,,) <$> parseJSON (V.unsafeIndex abcd 0)
788+ then (,,,) <$> parseJSONElemAtIndex 0 abcd
783− <*> parseJSON (V.unsafeIndex abcd 1)
789+ <*> parseJSONElemAtIndex 1 abcd
784− <*> parseJSON (V.unsafeIndex abcd 2)
790+ <*> parseJSONElemAtIndex 2 abcd
785− <*> parseJSON (V.unsafeIndex abcd 3)
791+ <*> parseJSONElemAtIndex 3 abcd
786 else fail $ "cannot unpack array of length " ++
792 else fail $ "cannot unpack array of length " ++
787 show n ++ " into a 4-tuple"
793 show n ++ " into a 4-tuple"
788 {-# INLINE parseJSON #-}
794 {-# INLINE parseJSON #-}
@@ -811,11 +817,11 @@ instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e) =>
811 parseJSON = withArray "(a,b,c,d,e)" $ \abcde ->
817 parseJSON = withArray "(a,b,c,d,e)" $ \abcde ->
812 let n = V.length abcde
818 let n = V.length abcde
813 in if n == 5
819 in if n == 5
814− then (,,,,) <$> parseJSON (V.unsafeIndex abcde 0)
820+ then (,,,,) <$> parseJSONElemAtIndex 0 abcde
815− <*> parseJSON (V.unsafeIndex abcde 1)
821+ <*> parseJSONElemAtIndex 1 abcde
816− <*> parseJSON (V.unsafeIndex abcde 2)
822+ <*> parseJSONElemAtIndex 2 abcde
817− <*> parseJSON (V.unsafeIndex abcde 3)
823+ <*> parseJSONElemAtIndex 3 abcde
818− <*> parseJSON (V.unsafeIndex abcde 4)
824+ <*> parseJSONElemAtIndex 4 abcde
819 else fail $ "cannot unpack array of length " ++
825 else fail $ "cannot unpack array of length " ++
820 show n ++ " into a 5-tuple"
826 show n ++ " into a 5-tuple"
821 {-# INLINE parseJSON #-}
827 {-# INLINE parseJSON #-}
@@ -846,12 +852,12 @@ instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
846 parseJSON = withArray "(a,b,c,d,e,f)" $ \abcdef ->
852 parseJSON = withArray "(a,b,c,d,e,f)" $ \abcdef ->
847 let n = V.length abcdef
853 let n = V.length abcdef
848 in if n == 6
854 in if n == 6
849− then (,,,,,) <$> parseJSON (V.unsafeIndex abcdef 0)
855+ then (,,,,,) <$> parseJSONElemAtIndex 0 abcdef
850− <*> parseJSON (V.unsafeIndex abcdef 1)
856+ <*> parseJSONElemAtIndex 1 abcdef
851− <*> parseJSON (V.unsafeIndex abcdef 2)
857+ <*> parseJSONElemAtIndex 2 abcdef
852− <*> parseJSON (V.unsafeIndex abcdef 3)
858+ <*> parseJSONElemAtIndex 3 abcdef
853− <*> parseJSON (V.unsafeIndex abcdef 4)
859+ <*> parseJSONElemAtIndex 4 abcdef
854− <*> parseJSON (V.unsafeIndex abcdef 5)
860+ <*> parseJSONElemAtIndex 5 abcdef
855 else fail $ "cannot unpack array of length " ++
861 else fail $ "cannot unpack array of length " ++
856 show n ++ " into a 6-tuple"
862 show n ++ " into a 6-tuple"
857 {-# INLINE parseJSON #-}
863 {-# INLINE parseJSON #-}
@@ -884,13 +890,13 @@ instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
884 parseJSON = withArray "(a,b,c,d,e,f,g)" $ \abcdefg ->
890 parseJSON = withArray "(a,b,c,d,e,f,g)" $ \abcdefg ->
885 let n = V.length abcdefg
891 let n = V.length abcdefg
886 in if n == 7
892 in if n == 7
887− then (,,,,,,) <$> parseJSON (V.unsafeIndex abcdefg 0)
893+ then (,,,,,,) <$> parseJSONElemAtIndex 0 abcdefg
888− <*> parseJSON (V.unsafeIndex abcdefg 1)
894+ <*> parseJSONElemAtIndex 1 abcdefg
889− <*> parseJSON (V.unsafeIndex abcdefg 2)
895+ <*> parseJSONElemAtIndex 2 abcdefg
890− <*> parseJSON (V.unsafeIndex abcdefg 3)
896+ <*> parseJSONElemAtIndex 3 abcdefg
891− <*> parseJSON (V.unsafeIndex abcdefg 4)
897+ <*> parseJSONElemAtIndex 4 abcdefg
892− <*> parseJSON (V.unsafeIndex abcdefg 5)
898+ <*> parseJSONElemAtIndex 5 abcdefg
893− <*> parseJSON (V.unsafeIndex abcdefg 6)
899+ <*> parseJSONElemAtIndex 6 abcdefg
894 else fail $ "cannot unpack array of length " ++
900 else fail $ "cannot unpack array of length " ++
895 show n ++ " into a 7-tuple"
901 show n ++ " into a 7-tuple"
896 {-# INLINE parseJSON #-}
902 {-# INLINE parseJSON #-}
@@ -929,14 +935,14 @@ instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
929 then fail $ "cannot unpack array of length " ++
935 then fail $ "cannot unpack array of length " ++
930 show n ++ " into an 8-tuple"
936 show n ++ " into an 8-tuple"
931 else (,,,,,,,)
937 else (,,,,,,,)
932− <$> parseJSON (V.unsafeIndex ary 0)
938+ <$> parseJSONElemAtIndex 0 ary
933− <*> parseJSON (V.unsafeIndex ary 1)
939+ <*> parseJSONElemAtIndex 1 ary
934− <*> parseJSON (V.unsafeIndex ary 2)
940+ <*> parseJSONElemAtIndex 2 ary
935− <*> parseJSON (V.unsafeIndex ary 3)
941+ <*> parseJSONElemAtIndex 3 ary
936− <*> parseJSON (V.unsafeIndex ary 4)
942+ <*> parseJSONElemAtIndex 4 ary
937− <*> parseJSON (V.unsafeIndex ary 5)
943+ <*> parseJSONElemAtIndex 5 ary
938− <*> parseJSON (V.unsafeIndex ary 6)
944+ <*> parseJSONElemAtIndex 6 ary
939− <*> parseJSON (V.unsafeIndex ary 7)
945+ <*> parseJSONElemAtIndex 7 ary
940 {-# INLINE parseJSON #-}
946 {-# INLINE parseJSON #-}
942instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
948instance (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,
975 then fail $ "cannot unpack array of length " ++
981 then fail $ "cannot unpack array of length " ++
976 show n ++ " into a 9-tuple"
982 show n ++ " into a 9-tuple"
977 else (,,,,,,,,)
983 else (,,,,,,,,)
978− <$> parseJSON (V.unsafeIndex ary 0)
984+ <$> parseJSONElemAtIndex 0 ary
979− <*> parseJSON (V.unsafeIndex ary 1)
985+ <*> parseJSONElemAtIndex 1 ary
980− <*> parseJSON (V.unsafeIndex ary 2)
986+ <*> parseJSONElemAtIndex 2 ary
981− <*> parseJSON (V.unsafeIndex ary 3)
987+ <*> parseJSONElemAtIndex 3 ary
982− <*> parseJSON (V.unsafeIndex ary 4)
988+ <*> parseJSONElemAtIndex 4 ary
983− <*> parseJSON (V.unsafeIndex ary 5)
989+ <*> parseJSONElemAtIndex 5 ary
984− <*> parseJSON (V.unsafeIndex ary 6)
990+ <*> parseJSONElemAtIndex 6 ary
985− <*> parseJSON (V.unsafeIndex ary 7)
991+ <*> parseJSONElemAtIndex 7 ary
986− <*> parseJSON (V.unsafeIndex ary 8)
992+ <*> parseJSONElemAtIndex 8 ary
987 {-# INLINE parseJSON #-}
993 {-# INLINE parseJSON #-}
989instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
995instance (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,
1025 then fail $ "cannot unpack array of length " ++
1031 then fail $ "cannot unpack array of length " ++
1026 show n ++ " into a 10-tuple"
1032 show n ++ " into a 10-tuple"
1027 else (,,,,,,,,,)
1033 else (,,,,,,,,,)
1028− <$> parseJSON (V.unsafeIndex ary 0)
1034+ <$> parseJSONElemAtIndex 0 ary
1029− <*> parseJSON (V.unsafeIndex ary 1)
1035+ <*> parseJSONElemAtIndex 1 ary
1030− <*> parseJSON (V.unsafeIndex ary 2)
1036+ <*> parseJSONElemAtIndex 2 ary
1031− <*> parseJSON (V.unsafeIndex ary 3)
1037+ <*> parseJSONElemAtIndex 3 ary
1032− <*> parseJSON (V.unsafeIndex ary 4)
1038+ <*> parseJSONElemAtIndex 4 ary
1033− <*> parseJSON (V.unsafeIndex ary 5)
1039+ <*> parseJSONElemAtIndex 5 ary
1034− <*> parseJSON (V.unsafeIndex ary 6)
1040+ <*> parseJSONElemAtIndex 6 ary
1035− <*> parseJSON (V.unsafeIndex ary 7)
1041+ <*> parseJSONElemAtIndex 7 ary
1036− <*> parseJSON (V.unsafeIndex ary 8)
1042+ <*> parseJSONElemAtIndex 8 ary
1037− <*> parseJSON (V.unsafeIndex ary 9)
1043+ <*> parseJSONElemAtIndex 9 ary
1038 {-# INLINE parseJSON #-}
1044 {-# INLINE parseJSON #-}
1040instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
1046instance (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,
1079 then fail $ "cannot unpack array of length " ++
1085 then fail $ "cannot unpack array of length " ++
1080 show n ++ " into an 11-tuple"
1086 show n ++ " into an 11-tuple"
1081 else (,,,,,,,,,,)
1087 else (,,,,,,,,,,)
1082− <$> parseJSON (V.unsafeIndex ary 0)
1088+ <$> parseJSONElemAtIndex 0 ary
1083− <*> parseJSON (V.unsafeIndex ary 1)
1089+ <*> parseJSONElemAtIndex 1 ary
1084− <*> parseJSON (V.unsafeIndex ary 2)
1090+ <*> parseJSONElemAtIndex 2 ary
1085− <*> parseJSON (V.unsafeIndex ary 3)
1091+ <*> parseJSONElemAtIndex 3 ary
1086− <*> parseJSON (V.unsafeIndex ary 4)
1092+ <*> parseJSONElemAtIndex 4 ary
1087− <*> parseJSON (V.unsafeIndex ary 5)
1093+ <*> parseJSONElemAtIndex 5 ary
1088− <*> parseJSON (V.unsafeIndex ary 6)
1094+ <*> parseJSONElemAtIndex 6 ary
1089− <*> parseJSON (V.unsafeIndex ary 7)
1095+ <*> parseJSONElemAtIndex 7 ary
1090− <*> parseJSON (V.unsafeIndex ary 8)
1096+ <*> parseJSONElemAtIndex 8 ary
1091− <*> parseJSON (V.unsafeIndex ary 9)
1097+ <*> parseJSONElemAtIndex 9 ary
1092− <*> parseJSON (V.unsafeIndex ary 10)
1098+ <*> parseJSONElemAtIndex 10 ary
1093 {-# INLINE parseJSON #-}
1099 {-# INLINE parseJSON #-}
1095instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
1101instance (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,
1136 then fail $ "cannot unpack array of length " ++
1142 then fail $ "cannot unpack array of length " ++
1137 show n ++ " into a 12-tuple"
1143 show n ++ " into a 12-tuple"
1138 else (,,,,,,,,,,,)
1144 else (,,,,,,,,,,,)
1139− <$> parseJSON (V.unsafeIndex ary 0)
1145+ <$> parseJSONElemAtIndex 0 ary
1140− <*> parseJSON (V.unsafeIndex ary 1)
1146+ <*> parseJSONElemAtIndex 1 ary
1141− <*> parseJSON (V.unsafeIndex ary 2)
1147+ <*> parseJSONElemAtIndex 2 ary
1142− <*> parseJSON (V.unsafeIndex ary 3)
1148+ <*> parseJSONElemAtIndex 3 ary
1143− <*> parseJSON (V.unsafeIndex ary 4)
1149+ <*> parseJSONElemAtIndex 4 ary
1144− <*> parseJSON (V.unsafeIndex ary 5)
1150+ <*> parseJSONElemAtIndex 5 ary
1145− <*> parseJSON (V.unsafeIndex ary 6)
1151+ <*> parseJSONElemAtIndex 6 ary
1146− <*> parseJSON (V.unsafeIndex ary 7)
1152+ <*> parseJSONElemAtIndex 7 ary
1147− <*> parseJSON (V.unsafeIndex ary 8)
1153+ <*> parseJSONElemAtIndex 8 ary
1148− <*> parseJSON (V.unsafeIndex ary 9)
1154+ <*> parseJSONElemAtIndex 9 ary
1149− <*> parseJSON (V.unsafeIndex ary 10)
1155+ <*> parseJSONElemAtIndex 10 ary
1150− <*> parseJSON (V.unsafeIndex ary 11)
1156+ <*> parseJSONElemAtIndex 11 ary
1151 {-# INLINE parseJSON #-}
1157 {-# INLINE parseJSON #-}
1153instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
1159instance (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,
1197 then fail $ "cannot unpack array of length " ++
1203 then fail $ "cannot unpack array of length " ++
1198 show n ++ " into a 13-tuple"
1204 show n ++ " into a 13-tuple"
1199 else (,,,,,,,,,,,,)
1205 else (,,,,,,,,,,,,)
1200− <$> parseJSON (V.unsafeIndex ary 0)
1206+ <$> parseJSONElemAtIndex 0 ary
1201− <*> parseJSON (V.unsafeIndex ary 1)
1207+ <*> parseJSONElemAtIndex 1 ary
1202− <*> parseJSON (V.unsafeIndex ary 2)
1208+ <*> parseJSONElemAtIndex 2 ary
1203− <*> parseJSON (V.unsafeIndex ary 3)
1209+ <*> parseJSONElemAtIndex 3 ary
1204− <*> parseJSON (V.unsafeIndex ary 4)
1210+ <*> parseJSONElemAtIndex 4 ary
1205− <*> parseJSON (V.unsafeIndex ary 5)
1211+ <*> parseJSONElemAtIndex 5 ary
1206− <*> parseJSON (V.unsafeIndex ary 6)
1212+ <*> parseJSONElemAtIndex 6 ary
1207− <*> parseJSON (V.unsafeIndex ary 7)
1213+ <*> parseJSONElemAtIndex 7 ary
1208− <*> parseJSON (V.unsafeIndex ary 8)
1214+ <*> parseJSONElemAtIndex 8 ary
1209− <*> parseJSON (V.unsafeIndex ary 9)
1215+ <*> parseJSONElemAtIndex 9 ary
1210− <*> parseJSON (V.unsafeIndex ary 10)
1216+ <*> parseJSONElemAtIndex 10 ary
1211− <*> parseJSON (V.unsafeIndex ary 11)
1217+ <*> parseJSONElemAtIndex 11 ary
1212− <*> parseJSON (V.unsafeIndex ary 12)
1218+ <*> parseJSONElemAtIndex 12 ary
1213 {-# INLINE parseJSON #-}
1219 {-# INLINE parseJSON #-}
1215instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
1221instance (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,
1261 then fail $ "cannot unpack array of length " ++
1267 then fail $ "cannot unpack array of length " ++
1262 show n ++ " into a 14-tuple"
1268 show n ++ " into a 14-tuple"
1263 else (,,,,,,,,,,,,,)
1269 else (,,,,,,,,,,,,,)
1264− <$> parseJSON (V.unsafeIndex ary 0)
1270+ <$> parseJSONElemAtIndex 0 ary
1265− <*> parseJSON (V.unsafeIndex ary 1)
1271+ <*> parseJSONElemAtIndex 1 ary
1266− <*> parseJSON (V.unsafeIndex ary 2)
1272+ <*> parseJSONElemAtIndex 2 ary
1267− <*> parseJSON (V.unsafeIndex ary 3)
1273+ <*> parseJSONElemAtIndex 3 ary
1268− <*> parseJSON (V.unsafeIndex ary 4)
1274+ <*> parseJSONElemAtIndex 4 ary
1269− <*> parseJSON (V.unsafeIndex ary 5)
1275+ <*> parseJSONElemAtIndex 5 ary
1270− <*> parseJSON (V.unsafeIndex ary 6)
1276+ <*> parseJSONElemAtIndex 6 ary
1271− <*> parseJSON (V.unsafeIndex ary 7)
1277+ <*> parseJSONElemAtIndex 7 ary
1272− <*> parseJSON (V.unsafeIndex ary 8)
1278+ <*> parseJSONElemAtIndex 8 ary
1273− <*> parseJSON (V.unsafeIndex ary 9)
1279+ <*> parseJSONElemAtIndex 9 ary
1274− <*> parseJSON (V.unsafeIndex ary 10)
1280+ <*> parseJSONElemAtIndex 10 ary
1275− <*> parseJSON (V.unsafeIndex ary 11)
1281+ <*> parseJSONElemAtIndex 11 ary
1276− <*> parseJSON (V.unsafeIndex ary 12)
1282+ <*> parseJSONElemAtIndex 12 ary
1277− <*> parseJSON (V.unsafeIndex ary 13)
1283+ <*> parseJSONElemAtIndex 13 ary
1278 {-# INLINE parseJSON #-}
1284 {-# INLINE parseJSON #-}
1280instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
1286instance (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,
1328 then fail $ "cannot unpack array of length " ++
1334 then fail $ "cannot unpack array of length " ++
1329 show n ++ " into a 15-tuple"
1335 show n ++ " into a 15-tuple"
1330 else (,,,,,,,,,,,,,,)
1336 else (,,,,,,,,,,,,,,)
1331− <$> parseJSON (V.unsafeIndex ary 0)
1337+ <$> parseJSONElemAtIndex 0 ary
1332− <*> parseJSON (V.unsafeIndex ary 1)
1338+ <*> parseJSONElemAtIndex 1 ary
1333− <*> parseJSON (V.unsafeIndex ary 2)
1339+ <*> parseJSONElemAtIndex 2 ary
1334− <*> parseJSON (V.unsafeIndex ary 3)
1340+ <*> parseJSONElemAtIndex 3 ary
1335− <*> parseJSON (V.unsafeIndex ary 4)
1341+ <*> parseJSONElemAtIndex 4 ary
1336− <*> parseJSON (V.unsafeIndex ary 5)
1342+ <*> parseJSONElemAtIndex 5 ary
1337− <*> parseJSON (V.unsafeIndex ary 6)
1343+ <*> parseJSONElemAtIndex 6 ary
1338− <*> parseJSON (V.unsafeIndex ary 7)
1344+ <*> parseJSONElemAtIndex 7 ary
1339− <*> parseJSON (V.unsafeIndex ary 8)
1345+ <*> parseJSONElemAtIndex 8 ary
1340− <*> parseJSON (V.unsafeIndex ary 9)
1346+ <*> parseJSONElemAtIndex 9 ary
1341− <*> parseJSON (V.unsafeIndex ary 10)
1347+ <*> parseJSONElemAtIndex 10 ary
1342− <*> parseJSON (V.unsafeIndex ary 11)
1348+ <*> parseJSONElemAtIndex 11 ary
1343− <*> parseJSON (V.unsafeIndex ary 12)
1349+ <*> parseJSONElemAtIndex 12 ary
1344− <*> parseJSON (V.unsafeIndex ary 13)
1350+ <*> parseJSONElemAtIndex 13 ary
1345− <*> parseJSON (V.unsafeIndex ary 14)
1351+ <*> parseJSONElemAtIndex 14 ary
1346 {-# INLINE parseJSON #-}
1352 {-# INLINE parseJSON #-}
1348instance ToJSON a => ToJSON (Dual a) where
1354instance ToJSON a => ToJSON (Dual a) where
@@ -1437,7 +1443,7 @@ fromJSON = parse parseJSON
1437(.:) :: (FromJSON a) => Object -> Text -> Parser a
1443(.:) :: (FromJSON a) => Object -> Text -> Parser a
1438obj .: key = case H.lookup key obj of
1444obj .: key = case H.lookup key obj of
1439 Nothing -> fail $ "key " ++ show key ++ " not present"
1445 Nothing -> fail $ "key " ++ show key ++ " not present"
1440− Just v -> parseJSON v
1446+ Just v -> parseJSON v <?> Key key
1441{-# INLINE (.:) #-}
1447{-# INLINE (.:) #-}
1443-- | Retrieve the value associated with the given key of an 'Object'.
1449-- | Retrieve the value associated with the given key of an 'Object'.
@@ -1450,7 +1456,7 @@ obj .: key = case H.lookup key obj of
1450(.:?) :: (FromJSON a) => Object -> Text -> Parser (Maybe a)
1456(.:?) :: (FromJSON a) => Object -> Text -> Parser (Maybe a)
1451obj .:? key = case H.lookup key obj of
1457obj .:? key = case H.lookup key obj of
1452 Nothing -> pure Nothing
1458 Nothing -> pure Nothing
1453− Just v -> parseJSON v
1459+ Just v -> parseJSON v <?> Key key
1454{-# INLINE (.:?) #-}
1460{-# INLINE (.:?) #-}
1456-- | Helper for use in combination with '.:?' to provide default
1462-- | Helper for use in combination with '.:?' to provide default