on master help sign in
Drop support for older bytestring and text
commit1bd16d5959ddfa267f71168db85c9b40f3a2045a authorBryan O'Sullivan <bryano@fb.com> dateWed 30 Apr 2014, 13:14 (12 years ago) parent4eaac49
7 files changed+8−52
Data/Aeson/Encode.hs+1−1 Data/Aeson/Parser/Internal.hs+4−11 Data/Aeson/TH.hs−4 Data/Aeson/Types/Internal.hs+1−1 aeson.cabal+1−9 benchmarks/AesonEncode.hs+1−11 benchmarks/CompareWithJSON.hs−15
Data/Aeson/Encode.hs+1−1
@@ -1,4 +1,4 @@
1−{-# LANGUAGE CPP, BangPatterns, OverloadedStrings #-}
1+{-# LANGUAGE BangPatterns, OverloadedStrings #-}
22
33-- |
44-- Module: Data.Aeson.Encode
Data/Aeson/Parser/Internal.hs+4−11
@@ -1,4 +1,4 @@
1−{-# LANGUAGE CPP, BangPatterns, OverloadedStrings #-}
1+{-# LANGUAGE BangPatterns, OverloadedStrings #-}
22
33-- |
44-- Module: Data.Aeson.Parser.Internal
@@ -123,7 +123,7 @@ array_' = {-# SCC "array_'" #-} do
123123
124124commaSeparated :: Parser a -> Word8 -> Parser [a]
125125commaSeparated item endByte = do
126− w <- peekWord8'
126+ w <- A.peekWord8'
127127 if w == endByte
128128 then A.anyWord8 >> return []
129129 else loop
@@ -154,7 +154,7 @@ arrayValues val = do
154154-- to preserve interoperability and security.
155155value :: Parser Value
156156value = do
157− w <- peekWord8'
157+ w <- A.peekWord8'
158158 case w of
159159 DOUBLE_QUOTE -> A.anyWord8 *> (String <$> jstring_)
160160 OPEN_CURLY -> A.anyWord8 *> object_
@@ -169,7 +169,7 @@ value = do
169169-- | Strict version of 'value'. See also 'json''.
170170value' :: Parser Value
171171value' = do
172− w <- peekWord8'
172+ w <- A.peekWord8'
173173 case w of
174174 DOUBLE_QUOTE -> do
175175 !s <- A.anyWord8 *> jstring_
@@ -324,10 +324,3 @@ jsonEOF' = json' <* skipSpace <* endOfInput
324324toByteString :: Builder -> ByteString
325325toByteString = L.toStrict . toLazyByteString
326326{-# INLINE toByteString #-}
327−
328−peekWord8' :: A.Parser Word8
329−#if MIN_VERSION_attoparsec(0,11,1)
330−peekWord8' = A.peekWord8'
331−#else
332−peekWord8' = maybe (fail "not enough bytes") return =<< A.peekWord8
333−#endif
Data/Aeson/TH.hs−4
@@ -103,10 +103,6 @@ import Data.Maybe ( Maybe(Nothing, Just), catMaybes )
103103import Prelude ( String, (-), Integer, fromIntegral, error )
104104import Text.Printf ( printf )
105105import Text.Show ( show )
106−#if __GLASGOW_HASKELL__ < 700
107−import Control.Monad ( (>>=), (>>) )
108−import Prelude ( fromInteger )
109−#endif
110106-- from unordered-containers:
111107import qualified Data.HashMap.Strict as H ( lookup, toList )
112108-- from template-haskell:
Data/Aeson/Types/Internal.hs+1−1
@@ -1,4 +1,4 @@
1−{-# LANGUAGE CPP, DeriveDataTypeable, GeneralizedNewtypeDeriving, Rank2Types #-}
1+{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving, Rank2Types #-}
22
33-- |
44-- Module: Data.Aeson.Types.Internal
aeson.cabal+1−9
@@ -1,5 +1,5 @@
11name: aeson
2−version: 0.7.0.4
2+version: 0.7.1.0
33license: BSD3
44license-file: LICENSE
55category: Text, Web, JSON
@@ -74,14 +74,6 @@ flag developer
7474 default: False
7575 manual: True
7676
77−flag blaze-builder
78− description: Use blaze-builder instead of bytestring >= 0.10
79− default: False
80−
81−flag new-bytestring-builder
82− description: Use the new bytestring builder available in bytestring >= 0.10.4.0
83− default: False
84−
8577library
8678 exposed-modules:
8779 Data.Aeson
benchmarks/AesonEncode.hs+1−11
@@ -1,4 +1,4 @@
1−{-# LANGUAGE BangPatterns, CPP, OverloadedStrings #-}
1+{-# LANGUAGE BangPatterns, OverloadedStrings #-}
22
33import Control.Exception
44import Control.Monad
@@ -11,16 +11,6 @@ import System.IO
1111import qualified Data.ByteString as B
1212import Control.DeepSeq
1313
14−#if !MIN_VERSION_bytestring(0,10,0)
15−import qualified Data.ByteString.Lazy.Internal as L
16−
17−instance NFData L.ByteString where
18− rnf = go
19− where go (L.Chunk _ cs) = go cs
20− go L.Empty = ()
21− {-# INLINE rnf #-}
22−#endif
23−
2414main :: IO ()
2515main = do
2616 args0 <- getArgs
benchmarks/CompareWithJSON.hs−15
@@ -1,4 +1,3 @@
1−{-# LANGUAGE CPP #-}
21{-# OPTIONS_GHC -fno-warn-orphans #-}
32
43import Blaze.ByteString.Builder (toLazyByteString)
@@ -13,14 +12,6 @@ import qualified Data.Text.Lazy as TL
1312import qualified Data.Text.Lazy.Builder as TLB
1413import qualified Data.Text.Lazy.Encoding as TLE
1514
16−#if !MIN_VERSION_bytestring(0,10,0)
17−import qualified Data.ByteString.Lazy.Internal as BL
18−
19−instance NFData BL.ByteString where
20− rnf (BL.Chunk _ bs) = rnf bs
21− rnf BL.Empty = ()
22−#endif
23−
2415instance (NFData v) => NFData (J.JSObject v) where
2516 rnf o = rnf (J.fromJSObject o)
2617
@@ -46,13 +37,11 @@ decodeA s = case A.decode s of
4637encodeJ :: J.JSValue -> BL.ByteString
4738encodeJ = toLazyByteString . fromString . J.encode
4839
49−#if MIN_VERSION_bytestring(0,10,4)
5040encodeToText :: A.Value -> TL.Text
5141encodeToText = TLB.toLazyText . A.encodeToTextBuilder . A.toJSON
5242
5343encodeViaText :: A.Value -> BL.ByteString
5444encodeViaText = TLE.encodeUtf8 . encodeToText
55−#endif
5645
5746main :: IO ()
5847main = do
@@ -76,18 +65,14 @@ main = do
7665 , bgroup "encode" [
7766 bgroup "en" [
7867 bench "aeson-to-bytestring" $ nf A.encode (decodeA enA)
79−#if MIN_VERSION_bytestring(0,10,4)
8068 , bench "aeson-via-text-to-bytestring" $ nf encodeViaText (decodeA enA)
8169 , bench "aeson-to-text" $ nf encodeToText (decodeA enA)
82−#endif
8370 , bench "json" $ nf encodeJ (decodeJ enJ)
8471 ]
8572 , bgroup "jp" [
8673 bench "aeson-to-bytestring" $ nf A.encode (decodeA jpA)
87−#if MIN_VERSION_bytestring(0,10,4)
8874 , bench "aeson-via-text-to-bytestring" $ nf encodeViaText (decodeA jpA)
8975 , bench "aeson-to-text" $ nf encodeToText (decodeA jpA)
90−#endif
9176 , bench "json" $ nf encodeJ (decodeJ jpJ)
9277 ]
9378 ]