@@ -125,6 +125,7 @@ instance (ToJSON a) => ToJSON (Maybe a) where
125125
126126 toEncoding (Just a) = toEncoding a
127127 toEncoding Nothing = Encoding E.null_
128+ {-# INLINE toEncoding #-}
128129
129130instance (FromJSON a) => FromJSON (Maybe a) where
130131 parseJSON Null = pure Nothing
@@ -140,6 +141,7 @@ instance (ToJSON a, ToJSON b) => ToJSON (Either a b) where
140141 B.shortByteString "{\"left\":" <> builder a <> B.char7 '}'
141142 toEncoding (Right a) = Encoding $
142143 B.shortByteString "{\"right\":" <> builder a <> B.char7 '}'
144+ {-# INLINE toEncoding #-}
143145
144146instance (FromJSON a, FromJSON b) => FromJSON (Either a b) where
145147 parseJSON (Object (H.toList -> [(key, value)]))
@@ -160,6 +162,7 @@ instance ToJSON Bool where
160162 {-# INLINE toJSON #-}
161163
162164 toEncoding = Encoding . E.bool
165+ {-# INLINE toEncoding #-}
163166
164167instance FromJSON Bool where
165168 parseJSON = withBool "Bool" pure
@@ -170,6 +173,7 @@ instance ToJSON () where
170173 {-# INLINE toJSON #-}
171174
172175 toEncoding _ = E.emptyArray_
176+ {-# INLINE toEncoding #-}
173177
174178instance FromJSON () where
175179 parseJSON = withArray "()" $ \v ->
@@ -183,6 +187,7 @@ instance ToJSON [Char] where
183187 {-# INLINE toJSON #-}
184188
185189 toEncoding = Encoding . E.string
190+ {-# INLINE toEncoding #-}
186191
187192instance FromJSON [Char] where
188193 parseJSON = withText "String" $ pure . T.unpack
@@ -193,6 +198,7 @@ instance ToJSON Char where
193198 {-# INLINE toJSON #-}
194199
195200 toEncoding = Encoding . E.string . (:[])
201+ {-# INLINE toEncoding #-}
196202
197203instance FromJSON Char where
198204 parseJSON = withText "Char" $ \t ->
@@ -253,11 +259,13 @@ instance ToJSON (Ratio Integer) where
253259 toJSON r = object [ "numerator" .= numerator r
254260 , "denominator" .= denominator r
255261 ]
262+ {-# INLINE toJSON #-}
256263
257264 toEncoding r = Encoding $
258265 B.shortByteString "{\"numerator\":" <> builder (numerator r) <>
259266 B.shortByteString ",\"denominator\":" <> builder (denominator r) <>
260267 B.char7 '}'
268+ {-# INLINE toEncoding #-}
261269
262270instance FromJSON (Ratio Integer) where
263271 parseJSON = withObject "Rational" $ \obj ->
@@ -270,6 +278,7 @@ instance HasResolution a => ToJSON (Fixed a) where
270278 {-# INLINE toJSON #-}
271279
272280 toEncoding = Encoding . E.number . realToFrac
281+ {-# INLINE toEncoding #-}
273282
274283-- | /WARNING:/ Only parse fixed-precision numbers from trusted input
275284-- since an attacker could easily fill up the memory of the target
@@ -295,6 +304,7 @@ instance ToJSON Integer where
295304 {-# INLINE toJSON #-}
296305
297306 toEncoding = Encoding . B.integerDec
307+ {-# INLINE toEncoding #-}
298308
299309-- | /WARNING:/ Only parse Integers from trusted input since an
300310-- attacker could easily fill up the memory of the target system by
@@ -309,6 +319,7 @@ instance ToJSON Int8 where
309319 {-# INLINE toJSON #-}
310320
311321 toEncoding = Encoding . B.int8Dec
322+ {-# INLINE toEncoding #-}
312323
313324instance FromJSON Int8 where
314325 parseJSON = parseIntegral "Int8"
@@ -319,6 +330,7 @@ instance ToJSON Int16 where
319330 {-# INLINE toJSON #-}
320331
321332 toEncoding = Encoding . B.int16Dec
333+ {-# INLINE toEncoding #-}
322334
323335instance FromJSON Int16 where
324336 parseJSON = parseIntegral "Int16"
@@ -329,6 +341,7 @@ instance ToJSON Int32 where
329341 {-# INLINE toJSON #-}
330342
331343 toEncoding = Encoding . B.int32Dec
344+ {-# INLINE toEncoding #-}
332345
333346instance FromJSON Int32 where
334347 parseJSON = parseIntegral "Int32"
@@ -339,6 +352,7 @@ instance ToJSON Int64 where
339352 {-# INLINE toJSON #-}
340353
341354 toEncoding = Encoding . B.int64Dec
355+ {-# INLINE toEncoding #-}
342356
343357instance FromJSON Int64 where
344358 parseJSON = parseIntegral "Int64"
@@ -349,6 +363,7 @@ instance ToJSON Word where
349363 {-# INLINE toJSON #-}
350364
351365 toEncoding = Encoding . B.wordDec
366+ {-# INLINE toEncoding #-}
352367
353368instance FromJSON Word where
354369 parseJSON = parseIntegral "Word"
@@ -359,6 +374,7 @@ instance ToJSON Word8 where
359374 {-# INLINE toJSON #-}
360375
361376 toEncoding = Encoding . B.word8Dec
377+ {-# INLINE toEncoding #-}
362378
363379instance FromJSON Word8 where
364380 parseJSON = parseIntegral "Word8"
@@ -369,6 +385,7 @@ instance ToJSON Word16 where
369385 {-# INLINE toJSON #-}
370386
371387 toEncoding = Encoding . B.word16Dec
388+ {-# INLINE toEncoding #-}
372389
373390instance FromJSON Word16 where
374391 parseJSON = parseIntegral "Word16"
@@ -379,6 +396,7 @@ instance ToJSON Word32 where
379396 {-# INLINE toJSON #-}
380397
381398 toEncoding = Encoding . B.word32Dec
399+ {-# INLINE toEncoding #-}
382400
383401instance FromJSON Word32 where
384402 parseJSON = parseIntegral "Word32"
@@ -389,6 +407,7 @@ instance ToJSON Word64 where
389407 {-# INLINE toJSON #-}
390408
391409 toEncoding = Encoding . B.word64Dec
410+ {-# INLINE toEncoding #-}
392411
393412instance FromJSON Word64 where
394413 parseJSON = parseIntegral "Word64"
@@ -399,6 +418,7 @@ instance ToJSON Text where
399418 {-# INLINE toJSON #-}
400419
401420 toEncoding = Encoding . E.text
421+ {-# INLINE toEncoding #-}
402422
403423instance FromJSON Text where
404424 parseJSON = withText "Text" pure
@@ -411,6 +431,7 @@ instance ToJSON LT.Text where
411431 toEncoding t = Encoding $
412432 B.char7 '"' <>
413433 LT.foldrChunks (\x xs -> E.unquoted x <> xs) (B.char7 '"') t
434+ {-# INLINE toEncoding #-}
414435
415436instance FromJSON LT.Text where
416437 parseJSON = withText "Lazy Text" $ pure . LT.fromStrict
@@ -421,6 +442,7 @@ instance (ToJSON a) => ToJSON [a] where
421442 {-# INLINE toJSON #-}
422443
423444 toEncoding xs = list xs
445+ {-# INLINE toEncoding #-}
424446
425447instance (FromJSON a) => FromJSON [a] where
426448 parseJSON = withArray "[a]" $ Tr.sequence .
@@ -432,6 +454,7 @@ instance (Foldable t, ToJSON a) => ToJSON (t a) where
432454 {-# INLINE toJSON #-}
433455
434456 toEncoding = foldable
457+ {-# INLINE toEncoding #-}
435458
436459instance (FromJSON a) => FromJSON (Seq.Seq a) where
437460 parseJSON = withArray "Seq a" $ traverse parseJSON . Seq.fromList . V.toList
@@ -442,6 +465,7 @@ instance (ToJSON a) => ToJSON (Vector a) where
442465 {-# INLINE toJSON #-}
443466
444467 toEncoding = encodeVector
468+ {-# INLINE toEncoding #-}
445469
446470encodeVector :: (ToJSON a, VG.Vector v a) => v a -> Encoding
447471encodeVector xs
@@ -450,6 +474,7 @@ encodeVector xs
450474 B.char7 '[' <> builder (VG.unsafeHead xs) <>
451475 VG.foldr go (B.char7 ']') (VG.unsafeTail xs)
452476 where go v b = B.char7 ',' <> builder v <> b
477+{-# INLINE encodeVector #-}
453478
454479instance (FromJSON a) => FromJSON (Vector a) where
455480 parseJSON = withArray "Vector a" $ V.mapM (uncurry parseIndexedJSON) .
@@ -466,33 +491,42 @@ vectorParseJSON s = withArray s $ fmap V.convert . V.mapM (uncurry parseIndexedJ
466491
467492instance (Storable a, ToJSON a) => ToJSON (VS.Vector a) where
468493 toJSON = vectorToJSON
494+ {-# INLINE toJSON #-}
469495
470496 toEncoding = encodeVector
497+ {-# INLINE toEncoding #-}
471498
472499instance (Storable a, FromJSON a) => FromJSON (VS.Vector a) where
473500 parseJSON = vectorParseJSON "Data.Vector.Storable.Vector a"
474501
475502instance (VP.Prim a, ToJSON a) => ToJSON (VP.Vector a) where
476503 toJSON = vectorToJSON
504+ {-# INLINE toJSON #-}
477505
478506 toEncoding = encodeVector
507+ {-# INLINE toEncoding #-}
479508
480509instance (VP.Prim a, FromJSON a) => FromJSON (VP.Vector a) where
481510 parseJSON = vectorParseJSON "Data.Vector.Primitive.Vector a"
511+ {-# INLINE parseJSON #-}
482512
483513instance (VG.Vector VU.Vector a, ToJSON a) => ToJSON (VU.Vector a) where
484514 toJSON = vectorToJSON
515+ {-# INLINE toJSON #-}
485516
486517 toEncoding = encodeVector
518+ {-# INLINE toEncoding #-}
487519
488520instance (VG.Vector VU.Vector a, FromJSON a) => FromJSON (VU.Vector a) where
489521 parseJSON = vectorParseJSON "Data.Vector.Unboxed.Vector a"
522+ {-# INLINE parseJSON #-}
490523
491524instance (ToJSON a) => ToJSON (Set.Set a) where
492525 toJSON = toJSON . Set.toList
493526 {-# INLINE toJSON #-}
494527
495528 toEncoding = encodeSet Set.minView Set.foldr
529+ {-# INLINE toEncoding #-}
496530
497531instance (Ord a, FromJSON a) => FromJSON (Set.Set a) where
498532 parseJSON = fmap Set.fromList . parseJSON
@@ -503,6 +537,7 @@ instance (ToJSON a) => ToJSON (HashSet.HashSet a) where
503537 {-# INLINE toJSON #-}
504538
505539 toEncoding = foldable
540+ {-# INLINE toEncoding #-}
506541
507542instance (Eq a, Hashable a, FromJSON a) => FromJSON (HashSet.HashSet a) where
508543 parseJSON = fmap HashSet.fromList . parseJSON
@@ -513,6 +548,7 @@ instance ToJSON IntSet.IntSet where
513548 {-# INLINE toJSON #-}
514549
515550 toEncoding = encodeSet IntSet.minView IntSet.foldr
551+ {-# INLINE toEncoding #-}
516552
517553encodeSet :: (ToJSON a) =>
518554 (s -> Maybe (a, s))
@@ -524,6 +560,7 @@ encodeSet minView foldr xs =
524560 Just (m,ys) -> Encoding $
525561 B.char7 '[' <> builder m <> foldr go (B.char7 ']') ys
526562 where go v b = B.char7 ',' <> builder v <> b
563+{-# INLINE encodeSet #-}
527564
528565instance FromJSON IntSet.IntSet where
529566 parseJSON = fmap IntSet.fromList . parseJSON
@@ -534,6 +571,7 @@ instance ToJSON a => ToJSON (IntMap.IntMap a) where
534571 {-# INLINE toJSON #-}
535572
536573 toEncoding = toEncoding . IntMap.toList
574+ {-# INLINE toEncoding #-}
537575
538576instance FromJSON a => FromJSON (IntMap.IntMap a) where
539577 parseJSON = fmap IntMap.fromList . parseJSON
@@ -544,6 +582,7 @@ instance (ToJSON v) => ToJSON (M.Map Text v) where
544582 {-# INLINE toJSON #-}
545583
546584 toEncoding = encodeMap M.minViewWithKey M.foldrWithKey
585+ {-# INLINE toEncoding #-}
547586
548587encodeMap :: (ToJSON k, ToJSON v) =>
549588 (m -> Maybe ((k,v), m))
@@ -556,15 +595,18 @@ encodeMap minViewWithKey foldrWithKey xs =
556595 B.char7 '{' <> encodeKV k v <>
557596 foldrWithKey go (B.char7 '}') ys
558597 where go k v b = B.char7 ',' <> encodeKV k v <> b
598+{-# INLINE encodeMap #-}
559599
560600encodeWithKey :: (ToJSON k, ToJSON v) =>
561601 ((k -> v -> Series -> Series) -> Series -> m -> Series)
562602 -> m -> Encoding
563603encodeWithKey foldrWithKey = brackets '{' '}' . foldrWithKey go mempty
564604 where go k v c = Value (Encoding $ encodeKV k v) <> c
605+{-# INLINE encodeWithKey #-}
565606
566607encodeKV :: (ToJSON k, ToJSON v) => k -> v -> B.Builder
567608encodeKV k v = builder k <> B.char7 ':' <> builder v
609+{-# INLINE encodeKV #-}
568610
569611instance (FromJSON v) => FromJSON (M.Map Text v) where
570612 parseJSON = withObject "Map Text a" $
@@ -572,58 +614,76 @@ instance (FromJSON v) => FromJSON (M.Map Text v) where
572614
573615instance (ToJSON v) => ToJSON (M.Map LT.Text v) where
574616 toJSON = Object . mapHashKeyVal LT.toStrict toJSON
617+ {-# INLINE toJSON #-}
575618
576619 toEncoding = encodeMap M.minViewWithKey M.foldrWithKey
620+ {-# INLINE toEncoding #-}
577621
578622instance (FromJSON v) => FromJSON (M.Map LT.Text v) where
579623 parseJSON = fmap (hashMapKey LT.fromStrict) . parseJSON
624+ {-# INLINE parseJSON #-}
580625
581626instance (ToJSON v) => ToJSON (M.Map String v) where
582627 toJSON = Object . mapHashKeyVal pack toJSON
628+ {-# INLINE toJSON #-}
583629
584630 toEncoding = encodeMap M.minViewWithKey M.foldrWithKey
631+ {-# INLINE toEncoding #-}
585632
586633instance (FromJSON v) => FromJSON (M.Map String v) where
587634 parseJSON = fmap (hashMapKey unpack) . parseJSON
635+ {-# INLINE parseJSON #-}
588636
589637instance (ToJSON v) => ToJSON (H.HashMap Text v) where
590638 toJSON = Object . H.map toJSON
591639 {-# INLINE toJSON #-}
592640
593641 toEncoding = encodeWithKey H.foldrWithKey
642+ {-# INLINE toEncoding #-}
594643
595644instance (FromJSON v) => FromJSON (H.HashMap Text v) where
596645 parseJSON = withObject "HashMap Text a" $ H.traverseWithKey (\k v -> parseJSON v <?> Key k)
646+ {-# INLINE parseJSON #-}
597647
598648instance (ToJSON v) => ToJSON (H.HashMap LT.Text v) where
599649 toJSON = Object . mapKeyVal LT.toStrict toJSON
650+ {-# INLINE toJSON #-}
600651
601652 toEncoding = encodeWithKey H.foldrWithKey
653+ {-# INLINE toEncoding #-}
602654
603655instance (FromJSON v) => FromJSON (H.HashMap LT.Text v) where
604656 parseJSON = fmap (mapKey LT.fromStrict) . parseJSON
657+ {-# INLINE parseJSON #-}
605658
606659instance (ToJSON v) => ToJSON (H.HashMap String v) where
607660 toJSON = Object . mapKeyVal pack toJSON
661+ {-# INLINE toJSON #-}
608662
609663 toEncoding = encodeWithKey H.foldrWithKey
664+ {-# INLINE toEncoding #-}
610665
611666instance (FromJSON v) => FromJSON (H.HashMap String v) where
612667 parseJSON = fmap (mapKey unpack) . parseJSON
668+ {-# INLINE parseJSON #-}
613669
614670instance (ToJSON v) => ToJSON (Tree.Tree v) where
615671 toJSON (Tree.Node root branches) = toJSON (root,branches)
672+ {-# INLINE toJSON #-}
616673
617674 toEncoding (Tree.Node root branches) = toEncoding (root,branches)
675+ {-# INLINE toEncoding #-}
618676
619677instance (FromJSON v) => FromJSON (Tree.Tree v) where
620678 parseJSON j = uncurry Tree.Node <$> parseJSON j
679+ {-# INLINE parseJSON #-}
621680
622681instance ToJSON Value where
623682 toJSON a = a
624683 {-# INLINE toJSON #-}
625684
626685 toEncoding = Encoding . E.encodeToBuilder
686+ {-# INLINE toEncoding #-}
627687
628688instance FromJSON Value where
629689 parseJSON a = pure a
@@ -631,7 +691,6 @@ instance FromJSON Value where
631691
632692instance ToJSON DotNetTime where
633693 toJSON = toJSON . dotNetTime
634− {-# INLINE toJSON #-}
635694
636695 toEncoding = toEncoding . dotNetTime
637696
@@ -701,7 +760,6 @@ instance FromJSON ZonedTime where
701760
702761instance ToJSON UTCTime where
703762 toJSON = toJSON . utcTime
704− {-# INLINE toJSON #-}
705763
706764 toEncoding = toEncoding . utcTime
707765
@@ -714,7 +772,6 @@ instance FromJSON UTCTime where
714772 case parseTime defaultTimeLocale "%FT%T%QZ" (unpack t) of
715773 Just d -> pure d
716774 _ -> fail "could not parse ISO-8601 date"
717− {-# INLINE parseJSON #-}
718775
719776parseJSONElemAtIndex :: FromJSON a => Int -> Vector Value -> Parser a
720777parseJSONElemAtIndex idx ary = parseJSON (V.unsafeIndex ary idx) <?> Index idx
@@ -824,6 +881,7 @@ instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e) =>
824881 builder c >*<
825882 builder d >*<
826883 builder e
884+ {-# INLINE toEncoding #-}
827885
828886instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e) =>
829887 FromJSON (a,b,c,d,e) where
@@ -859,6 +917,7 @@ instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f) =>
859917 builder d >*<
860918 builder e >*<
861919 builder f
920+ {-# INLINE toEncoding #-}
862921
863922instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
864923 FromJSON f) => FromJSON (a,b,c,d,e,f) where
@@ -897,6 +956,7 @@ instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
897956 builder e >*<
898957 builder f >*<
899958 builder g
959+ {-# INLINE toEncoding #-}
900960
901961instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
902962 FromJSON f, FromJSON g) => FromJSON (a,b,c,d,e,f,g) where
@@ -938,6 +998,7 @@ instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
938998 builder f >*<
939999 builder g >*<
9401000 builder h
1001+ {-# INLINE toEncoding #-}
9411002
9421003instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
9431004 FromJSON f, FromJSON g, FromJSON h) =>
@@ -984,6 +1045,7 @@ instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
9841045 builder g >*<
9851046 builder h >*<
9861047 builder i
1048+ {-# INLINE toEncoding #-}
9871049
9881050instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
9891051 FromJSON f, FromJSON g, FromJSON h, FromJSON i) =>
@@ -1034,6 +1096,7 @@ instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
10341096 builder h >*<
10351097 builder i >*<
10361098 builder j
1099+ {-# INLINE toEncoding #-}
10371100
10381101instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
10391102 FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j) =>
@@ -1087,6 +1150,7 @@ instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
10871150 builder i >*<
10881151 builder j >*<
10891152 builder k
1153+ {-# INLINE toEncoding #-}
10901154
10911155instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
10921156 FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j,
@@ -1144,6 +1208,7 @@ instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
11441208 builder j >*<
11451209 builder k >*<
11461210 builder l
1211+ {-# INLINE toEncoding #-}
11471212
11481213instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
11491214 FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j,
@@ -1205,6 +1270,7 @@ instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
12051270 builder k >*<
12061271 builder l >*<
12071272 builder m
1273+ {-# INLINE toEncoding #-}
12081274
12091275instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
12101276 FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j,
@@ -1269,6 +1335,7 @@ instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
12691335 builder l >*<
12701336 builder m >*<
12711337 builder n
1338+ {-# INLINE toEncoding #-}
12721339
12731340instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
12741341 FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j,
@@ -1336,6 +1403,7 @@ instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f,
13361403 builder m >*<
13371404 builder n >*<
13381405 builder o
1406+ {-# INLINE toEncoding #-}
13391407
13401408instance (FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e,
13411409 FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j,
@@ -1369,6 +1437,7 @@ instance ToJSON a => ToJSON (Dual a) where
13691437 {-# INLINE toJSON #-}
13701438
13711439 toEncoding = toEncoding . getDual
1440+ {-# INLINE toEncoding #-}
13721441
13731442instance FromJSON a => FromJSON (Dual a) where
13741443 parseJSON = fmap Dual . parseJSON
@@ -1379,6 +1448,7 @@ instance ToJSON a => ToJSON (First a) where
13791448 {-# INLINE toJSON #-}
13801449
13811450 toEncoding = toEncoding . getFirst
1451+ {-# INLINE toEncoding #-}
13821452
13831453instance FromJSON a => FromJSON (First a) where
13841454 parseJSON = fmap First . parseJSON
@@ -1389,6 +1459,7 @@ instance ToJSON a => ToJSON (Last a) where
13891459 {-# INLINE toJSON #-}
13901460
13911461 toEncoding = toEncoding . getLast
1462+ {-# INLINE toEncoding #-}
13921463
13931464instance FromJSON a => FromJSON (Last a) where
13941465 parseJSON = fmap Last . parseJSON