on master help sign in
Merge
4eaac49Bryan O'Sullivan
Data/Aeson/Encode.hs−16
@@ -19,14 +19,9 @@
19module Data.Aeson.Encode
19module Data.Aeson.Encode
20 ( encode
20 ( encode
21
21
22−#if MIN_VERSION_bytestring(0,10,4)
23 -- * Encoding to Builders
22 -- * Encoding to Builders
24 , encodeToByteStringBuilder
23 , encodeToByteStringBuilder
25 , encodeToTextBuilder
24 , encodeToTextBuilder
26−#else
27− -- * Encoding to Text Builders
28− , encodeToTextBuilder
29−#endif
30
25
31 -- * Deprecated
26 -- * Deprecated
32 , fromValue
27 , fromValue
@@ -42,18 +37,7 @@ import qualified Data.HashMap.Strict as H
42import qualified Data.Text as T
37import qualified Data.Text as T
43import qualified Data.Vector as V
38import qualified Data.Vector as V
44
39
45−#if MIN_VERSION_bytestring(0,10,4)
46import Data.Aeson.Encode.ByteString (encode, encodeToByteStringBuilder)
40import 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
57
41
58-- | Encode a JSON 'Value' to a 'Builder', which can be embedded efficiently
42-- | Encode a JSON 'Value' to a 'Builder', which can be embedded efficiently
59-- in a text-based protocol.
43-- in a text-based protocol.
Data/Aeson/Parser/Internal.hs−25
@@ -28,18 +28,8 @@ module Data.Aeson.Parser.Internal
28 , eitherDecodeStrictWith
28 , eitherDecodeStrictWith
29 ) where
29 ) where
30
30
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)
37import Data.ByteString.Builder
31import Data.ByteString.Builder
38−#else
39−import Data.ByteString.Lazy.Builder
40−#endif
41 (Builder, byteString, toLazyByteString, charUtf8, word8)
32 (Builder, byteString, toLazyByteString, charUtf8, word8)
42−#endif
43
33
44import Control.Applicative ((*>), (<$>), (<*), liftA2, pure)
34import Control.Applicative ((*>), (<$>), (<*), liftA2, pure)
45import Data.Aeson.Types (Result(..), Value(..))
35import Data.Aeson.Types (Result(..), Value(..))
@@ -331,24 +321,9 @@ jsonEOF = json <* skipSpace <* endOfInput
331jsonEOF' :: Parser Value
321jsonEOF' :: Parser Value
332jsonEOF' = json' <* skipSpace <* endOfInput
322jsonEOF' = json' <* skipSpace <* endOfInput
333
323
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
348toByteString :: Builder -> ByteString
324toByteString :: Builder -> ByteString
349toByteString = L.toStrict . toLazyByteString
325toByteString = L.toStrict . toLazyByteString
350{-# INLINE toByteString #-}
326{-# INLINE toByteString #-}
351−#endif
352
327
353peekWord8' :: A.Parser Word8
328peekWord8' :: A.Parser Word8
354#if MIN_VERSION_attoparsec(0,11,1)
329#if MIN_VERSION_attoparsec(0,11,1)
aeson.cabal+7−15
@@ -97,14 +97,7 @@ library
97 Data.Aeson.Types.Class
97 Data.Aeson.Types.Class
98 Data.Aeson.Types.Instances
98 Data.Aeson.Types.Instances
99 Data.Aeson.Types.Internal
99 Data.Aeson.Types.Internal
100−
101− if flag(new-bytestring-builder)
102− other-modules: Data.Aeson.Encode.ByteString
100+ 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
108
101
109 if impl(ghc >= 7.2.1)
102 if impl(ghc >= 7.2.1)
110 cpp-options: -DGENERICS
103 cpp-options: -DGENERICS
@@ -112,9 +105,13 @@ library
112 other-modules:
105 other-modules:
113 Data.Aeson.Types.Generic
106 Data.Aeson.Types.Generic
114
107
108+ if impl(ghc < 7.8)
109+ build-depends: bytestring-builder
110+
115 build-depends:
111 build-depends:
116 attoparsec >= 0.11.3.0,
112 attoparsec >= 0.11.3.0,
117 base == 4.*,
113 base == 4.*,
114+ bytestring >= 0.10.4.0,
118 containers,
115 containers,
119 deepseq,
116 deepseq,
120 hashable >= 1.1.2.0,
117 hashable >= 1.1.2.0,
@@ -125,13 +122,8 @@ library
125 time,
122 time,
126 unordered-containers >= 0.2.3.0,
123 unordered-containers >= 0.2.3.0,
127 vector >= 0.7.1,
124 vector >= 0.7.1,
128− scientific >= 0.2
125+ scientific >= 0.2,
129−
126+ text >= 1.1.1.0
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
135
127
136 if flag(developer)
128 if flag(developer)
137 ghc-options: -Werror
129 ghc-options: -Werror