on master help sign in
Bump lower bound for aeson + drop code for aeson <=0.7.0

as using older aeson is not good idea anyway...

commit4beaa8b00d20806725f12bb1da5c26168b5d3657 authorMatej Kollar <208115@mail.muni.cz> dateSun 6 Sep 2015, 10:49 (11 years ago) parentc505144
5 files changed+4−44
Data/Yaml.hs−8 Data/Yaml/Builder.hs−16 Data/Yaml/Internal.hs−12 test/Data/YamlSpec.hs−4 yaml.cabal+4−4
Data/Yaml.hs−8
@@ -71,14 +71,10 @@ import qualified Data.Vector as V
7171import Data.Text.Encoding (encodeUtf8)
7272import qualified Data.HashMap.Strict as M
7373import qualified Data.HashSet as HashSet
74−#if MIN_VERSION_aeson(0, 7, 0)
7574import qualified Data.Text.Encoding as TE
7675import qualified Data.Text.Lazy as TL
7776import Data.Text.Lazy.Builder (toLazyText)
7877import Data.Aeson.Encode (encodeToTextBuilder)
79−#else
80−import qualified Data.ByteString.Char8 as S8
81−#endif
8278import Control.Monad.Trans.Resource (runResourceT)
8379
8480import Data.Yaml.Internal
@@ -130,12 +126,8 @@ objToEvents' (String s) rest =
130126objToEvents' Null rest = EventScalar "null" NullTag PlainNoTag Nothing : rest
131127objToEvents' (Bool True) rest = EventScalar "true" BoolTag PlainNoTag Nothing : rest
132128objToEvents' (Bool False) rest = EventScalar "false" BoolTag PlainNoTag Nothing : rest
133−#if MIN_VERSION_aeson(0,7,0)
134129-- Use aeson's implementation which gets rid of annoying decimal points
135130objToEvents' n@Number{} rest = EventScalar (TE.encodeUtf8 $ TL.toStrict $ toLazyText $ encodeToTextBuilder n) IntTag PlainNoTag Nothing : rest
136−#else
137−objToEvents' (Number n) rest = EventScalar (S8.pack $ show n) IntTag PlainNoTag Nothing : rest
138−#endif
139131
140132pairToEvents :: Pair -> [Y.Event] -> [Y.Event]
141133pairToEvents (k, v) rest =
Data/Yaml/Builder.hs−16
@@ -23,24 +23,18 @@ import Data.ByteString (ByteString)
2323import Text.Libyaml
2424import Data.Yaml.Internal
2525import Data.Text (Text)
26−#if MIN_VERSION_aeson(0, 7, 0)
2726import Data.Scientific (Scientific)
2827import Data.Aeson.Types (Value(..))
29−#endif
3028import qualified Data.HashSet as HashSet
3129import Data.Text.Encoding (encodeUtf8)
3230import System.IO.Unsafe (unsafePerformIO)
3331import Control.Arrow (second)
3432import qualified Data.ByteString.Char8 as S8
3533import Control.Monad.Trans.Resource (runResourceT)
36−#if MIN_VERSION_aeson(0, 7, 0)
3734import qualified Data.Text.Encoding as TE
3835import qualified Data.Text.Lazy as TL
3936import Data.Text.Lazy.Builder (toLazyText)
4037import Data.Aeson.Encode (encodeToTextBuilder)
41−#else
42−import Data.Attoparsec.Number
43−#endif
4438import Prelude hiding (null)
4539
4640(.=) :: ToYaml a => Text -> a -> (Text, YamlBuilder)
@@ -89,22 +83,12 @@ string s =
8983 | otherwise = EventScalar (encodeUtf8 s) StrTag PlainNoTag Nothing
9084
9185-- Use aeson's implementation which gets rid of annoying decimal points
92−#if MIN_VERSION_aeson(0, 7, 0)
9386scientific :: Scientific -> YamlBuilder
9487scientific n = YamlBuilder (EventScalar (TE.encodeUtf8 $ TL.toStrict $ toLazyText $ encodeToTextBuilder (Number n)) IntTag PlainNoTag Nothing :)
95−#else
96−scientific :: Number -> YamlBuilder
97−scientific n = YamlBuilder (EventScalar (S8.pack $ show n) IntTag PlainNoTag Nothing :)
98−#endif
9988
10089{-# DEPRECATED number "Use scientific" #-}
101−#if MIN_VERSION_aeson(0,7,0)
10290number :: Scientific -> YamlBuilder
10391number = scientific
104−#else
105−number :: Number -> YamlBuilder
106−number n = YamlBuilder (EventScalar (S8.pack $ show n) IntTag PlainNoTag Nothing :)
107−#endif
10892
10993bool :: Bool -> YamlBuilder
11094bool True = YamlBuilder (EventScalar "true" BoolTag PlainNoTag Nothing :)
Data/Yaml/Internal.hs−12
@@ -38,13 +38,8 @@ import Data.Text.Encoding (decodeUtf8With)
3838import Data.Text.Encoding.Error (lenientDecode)
3939import qualified Data.HashMap.Strict as M
4040import Data.Typeable
41−#if MIN_VERSION_aeson(0, 7, 0)
4241import qualified Data.Attoparsec.Text as Atto
4342import Data.Scientific (Scientific)
44−#else
45−import Data.Text.Read
46−import Data.Attoparsec.Number
47−#endif
4843import Control.Monad.Trans.Resource (ResourceT, runResourceT)
4944import qualified Data.HashSet as HashSet
5045
@@ -163,20 +158,13 @@ textToValue _ _ t
163158 | t `elem` ["null", "Null", "NULL", "~", ""] = Null
164159 | any (t `isLike`) ["y", "yes", "on", "true"] = Bool True
165160 | any (t `isLike`) ["n", "no", "off", "false"] = Bool False
166−#if MIN_VERSION_aeson(0, 7, 0)
167161 | Right x <- textToScientific t = Number x
168−#else
169− | Right (x, "") <- signed decimal t = Number $ I x
170− | Right (x, "") <- double t = Number $ D x
171−#endif
172162 | otherwise = String t
173163 where x `isLike` ref = x `elem` [ref, T.toUpper ref, titleCased]
174164 where titleCased = toUpper (T.head ref) `T.cons` T.tail ref
175165
176−#if MIN_VERSION_aeson(0, 7, 0)
177166textToScientific :: Text -> Either String Scientific
178167textToScientific = Atto.parseOnly (Atto.scientific <* Atto.endOfInput)
179−#endif
180168
181169parseO :: C.Sink Event Parse Value
182170parseO = do
test/Data/YamlSpec.hs−4
@@ -148,9 +148,7 @@ spec = do
148148 it "serialization of +123 #64" $ do
149149 D.decode (D.encode ("+123" :: String)) `shouldBe` Just ("+123" :: String)
150150
151−#if MIN_VERSION_aeson(0, 7, 0)
152151 it "preserves Scientific precision" casePreservesScientificPrecision
153−#endif
154152
155153
156154specialStrings :: [T.Text]
@@ -470,7 +468,6 @@ caseIssue49 =
470468 where
471469 src = "---\na:\n &id5 value: 1.0\nb:\n *id5: 1.2"
472470
473−#if MIN_VERSION_aeson(0, 7, 0)
474471-- | We cannot guarantee this before aeson started using 'Scientific'.
475472casePreservesScientificPrecision :: Assertion
476473casePreservesScientificPrecision = do
@@ -487,4 +484,3 @@ casePreservesScientificPrecision = do
487484 -- results, because of <https://github.com/bos/text/issues/34>.
488485 D.decodeEither "x: 9.78159610558926e-5" @?= Right (object
489486 [ "x" .= D.Number (read "9.78159610558926e-5") ])
490−#endif
yaml.cabal+4−4
@@ -43,7 +43,7 @@ library
4343 , bytestring >= 0.9.1.4
4444 , conduit >= 1.1.0 && < 1.3
4545 , resourcet >= 0.3 && < 1.2
46− , aeson >= 0.5
46+ , aeson >= 0.7
4747 , containers
4848 , unordered-containers
4949 , vector
@@ -91,7 +91,7 @@ executable yaml2json
9191 build-depends: base >= 4 && < 5
9292 , yaml
9393 , bytestring >= 0.9.1.4
94− , aeson >= 0.5
94+ , aeson >= 0.7
9595
9696executable json2yaml
9797 if flag(no-exe)
@@ -104,7 +104,7 @@ executable json2yaml
104104 build-depends: base >= 4 && < 5
105105 , yaml
106106 , bytestring >= 0.9.1.4
107− , aeson >= 0.5
107+ , aeson >= 0.7
108108
109109
110110test-suite spec
@@ -122,7 +122,7 @@ test-suite spec
122122 , conduit
123123 , yaml
124124 , text
125− , aeson
125+ , aeson >= 0.7
126126 , unordered-containers
127127 , vector
128128 , resourcet