on master help sign in
Fix cabal-install for GHC 7.8; better support for GHC < 7.8

Proposed fix for #177. This does have the downside that it would immediately require text-1.1, which might cause for some people committed to older versions of the Haskell Platform.

commite342061e34fb60b0ef42d6d8070e7c7761949c22 authorLeon P Smith <leon@melding-monads.com> dateFri 10 Jan 2014, 19:06 (13 years ago) parent44ba006
3 files changed+8−57
Data/Aeson/Encode.hs−16 Data/Aeson/Parser/Internal.hs−25 aeson.cabal+8−16
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,21 +321,6 @@ 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
aeson.cabal+8−16
@@ -1,5 +1,5 @@
11name: aeson
2−version: 0.7.0.0
2+version: 0.7.0.1
33license: BSD3
44license-file: LICENSE
55category: Text, Web, JSON
@@ -96,14 +96,7 @@ library
9696 Data.Aeson.Types.Class
9797 Data.Aeson.Types.Instances
9898 Data.Aeson.Types.Internal
99−
100− if flag(new-bytestring-builder)
101− other-modules: Data.Aeson.Encode.ByteString
102− build-depends: bytestring >= 0.10.4.0,
103− text >= 1.1.0.0
104− else
105− build-depends: bytestring < 0.10.4.0,
106− text >= 0.11.1.0
99+ Data.Aeson.Encode.ByteString
107100
108101 if impl(ghc >= 7.2.1)
109102 cpp-options: -DGENERICS
@@ -111,9 +104,13 @@ library
111104 other-modules:
112105 Data.Aeson.Types.Generic
113106
107+ if impl(ghc < 7.8)
108+ build-depends: bytestring-builder
109+
114110 build-depends:
115111 attoparsec >= 0.11.1.0,
116112 base == 4.*,
113+ bytestring,
117114 containers,
118115 deepseq,
119116 hashable >= 1.1.2.0,
@@ -124,13 +121,8 @@ library
124121 time,
125122 unordered-containers >= 0.1.3.0,
126123 vector >= 0.7.1,
127− scientific >= 0.2
128−
129− if flag(blaze-builder)
130− build-depends: blaze-builder >= 0.2.1.4
131− cpp-options: -DUSE_BLAZE_BUILDER
132− else
133− build-depends: bytestring >= 0.10
124+ scientific >= 0.2,
125+ text >= 1.1.1.0
134126
135127 if flag(developer)
136128 ghc-options: -Werror