on master help sign in
Merge
commit4eaac494ee01c8e26cd6ad4a200848339681fb4d authorBryan O'Sullivan <bryano@fb.com> dateWed 30 Apr 2014, 13:08 (12 years ago) parent7aba9d9e342061
3 files changed+7−56
Data/Aeson/Encode.hs−16 Data/Aeson/Parser/Internal.hs−25 aeson.cabal+7−15
Data/Aeson/Encode.hs−16
@@ -19,14 +19,9 @@
1919module Data.Aeson.Encode
2020 ( encode
2121
22−#if MIN_VERSION_bytestring(0,10,4)
2322 -- * Encoding to Builders
2423 , encodeToByteStringBuilder
2524 , encodeToTextBuilder
26−#else
27− -- * Encoding to Text Builders
28− , encodeToTextBuilder
29−#endif
3025
3126 -- * Deprecated
3227 , fromValue
@@ -42,18 +37,7 @@ import qualified Data.HashMap.Strict as H
4237import qualified Data.Text as T
4338import qualified Data.Vector as V
4439
45−#if MIN_VERSION_bytestring(0,10,4)
4640import Data.Aeson.Encode.ByteString (encode, encodeToByteStringBuilder)
47−#else
48−import Data.Aeson.Types (ToJSON(toJSON))
49−import qualified Data.ByteString.Lazy as BL
50−import qualified Data.Text.Lazy.Builder as TLB
51−import qualified Data.Text.Lazy.Encoding as TLE
52−
53−-- | Encode a JSON 'Value' as a UTF-8 encoded 'BL.ByteString'.
54−encode :: ToJSON a => a -> BL.ByteString
55−encode = TLE.encodeUtf8 . TLB.toLazyText . encodeToTextBuilder . toJSON
56−#endif
5741
5842-- | Encode a JSON 'Value' to a 'Builder', which can be embedded efficiently
5943-- in a text-based protocol.
Data/Aeson/Parser/Internal.hs−25
@@ -28,18 +28,8 @@ module Data.Aeson.Parser.Internal
2828 , eitherDecodeStrictWith
2929 ) where
3030
31−#if defined(USE_BLAZE_BUILDER)
32−import Blaze.ByteString.Builder (Builder, fromByteString, toByteString)
33−import Blaze.ByteString.Builder.Char.Utf8 (fromChar)
34−import Blaze.ByteString.Builder.Word (fromWord8)
35−#else
36−#if MIN_VERSION_bytestring(0,10,2)
3731import Data.ByteString.Builder
38−#else
39−import Data.ByteString.Lazy.Builder
40−#endif
4132 (Builder, byteString, toLazyByteString, charUtf8, word8)
42−#endif
4333
4434import Control.Applicative ((*>), (<$>), (<*), liftA2, pure)
4535import Data.Aeson.Types (Result(..), Value(..))
@@ -331,24 +321,9 @@ jsonEOF = json <* skipSpace <* endOfInput
331321jsonEOF' :: Parser Value
332322jsonEOF' = json' <* skipSpace <* endOfInput
333323
334−#if defined(USE_BLAZE_BUILDER)
335−byteString :: ByteString -> Builder
336−byteString = fromByteString
337−{-# INLINE byteString #-}
338−
339−charUtf8 :: Char -> Builder
340−charUtf8 = fromChar
341−{-# INLINE charUtf8 #-}
342−
343−word8 :: Word8 -> Builder
344−word8 = fromWord8
345−{-# INLINE word8 #-}
346−
347−#else
348324toByteString :: Builder -> ByteString
349325toByteString = L.toStrict . toLazyByteString
350326{-# INLINE toByteString #-}
351−#endif
352327
353328peekWord8' :: A.Parser Word8
354329#if MIN_VERSION_attoparsec(0,11,1)
aeson.cabal+7−15
@@ -97,14 +97,7 @@ library
9797 Data.Aeson.Types.Class
9898 Data.Aeson.Types.Instances
9999 Data.Aeson.Types.Internal
100−
101− if flag(new-bytestring-builder)
102− other-modules: Data.Aeson.Encode.ByteString
103− build-depends: bytestring >= 0.10.4.0,
104− text >= 1.1.0.0
105− else
106− build-depends: bytestring < 0.10.4.0,
107− text >= 0.11.1.0
100+ Data.Aeson.Encode.ByteString
108101
109102 if impl(ghc >= 7.2.1)
110103 cpp-options: -DGENERICS
@@ -112,9 +105,13 @@ library
112105 other-modules:
113106 Data.Aeson.Types.Generic
114107
108+ if impl(ghc < 7.8)
109+ build-depends: bytestring-builder
110+
115111 build-depends:
116112 attoparsec >= 0.11.3.0,
117113 base == 4.*,
114+ bytestring >= 0.10.4.0,
118115 containers,
119116 deepseq,
120117 hashable >= 1.1.2.0,
@@ -125,13 +122,8 @@ library
125122 time,
126123 unordered-containers >= 0.2.3.0,
127124 vector >= 0.7.1,
128− scientific >= 0.2
129−
130− if flag(blaze-builder)
131− build-depends: blaze-builder >= 0.2.1.4
132− cpp-options: -DUSE_BLAZE_BUILDER
133− else
134− build-depends: bytestring >= 0.10
125+ scientific >= 0.2,
126+ text >= 1.1.1.0
135127
136128 if flag(developer)
137129 ghc-options: -Werror