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