Hello community,
here is the log from the commit of package ghc-yaml for openSUSE:Factory checked in at 2015-09-17 09:19:53
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-yaml (Old)
and /work/SRC/openSUSE:Factory/.ghc-yaml.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-yaml"
Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-yaml/ghc-yaml.changes 2015-09-02 00:36:16.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.ghc-yaml.new/ghc-yaml.changes 2015-09-17 09:19:54.000000000 +0200
@@ -1,0 +2,6 @@
+Sun Sep 13 13:22:11 UTC 2015 - mimi.vx@gmail.com
+
+- update to 0.8.15.1
+* Parse Scientific directly, avoiding loss in precision.
+
+-------------------------------------------------------------------
Old:
----
yaml-0.8.14.tar.gz
New:
----
yaml-0.8.15.1.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ ghc-yaml.spec ++++++
--- /var/tmp/diff_new_pack.ORigb7/_old 2015-09-17 09:19:54.000000000 +0200
+++ /var/tmp/diff_new_pack.ORigb7/_new 2015-09-17 09:19:54.000000000 +0200
@@ -18,7 +18,7 @@
%global pkg_name yaml
Name: ghc-yaml
-Version: 0.8.14
+Version: 0.8.15.1
Release: 0
Summary: Support for parsing and rendering YAML documents
License: BSD-3-Clause
++++++ yaml-0.8.14.tar.gz -> yaml-0.8.15.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.14/ChangeLog.md new/yaml-0.8.15.1/ChangeLog.md
--- old/yaml-0.8.14/ChangeLog.md 2015-08-30 08:11:27.000000000 +0200
+++ new/yaml-0.8.15.1/ChangeLog.md 2015-09-06 10:27:33.000000000 +0200
@@ -1,3 +1,11 @@
+## 0.8.15.1
+
+* Compile with aeson below 0.7 [#70](https://github.com/snoyberg/yaml/pull/70)
+
+## 0.8.15
+
+* Parse `Scientific` directly, avoiding loss in precision. [#68](https://github.com/snoyberg/yaml/pull/68)
+
## 0.8.14
* Pretty print improvements for exceptions [#67](https://github.com/snoyberg/yaml/pull/67)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.14/Data/Yaml/Builder.hs new/yaml-0.8.15.1/Data/Yaml/Builder.hs
--- old/yaml-0.8.14/Data/Yaml/Builder.hs 2015-08-30 08:11:27.000000000 +0200
+++ new/yaml-0.8.15.1/Data/Yaml/Builder.hs 2015-09-06 10:27:33.000000000 +0200
@@ -23,10 +23,11 @@
import Text.Libyaml
import Data.Yaml.Internal
import Data.Text (Text)
+#if MIN_VERSION_aeson(0, 7, 0)
import Data.Scientific (Scientific)
import Data.Aeson.Types (Value(..))
+#endif
import qualified Data.HashSet as HashSet
-import qualified Data.Text as T
import Data.Text.Encoding (encodeUtf8)
import System.IO.Unsafe (unsafePerformIO)
import Control.Arrow (second)
@@ -38,7 +39,7 @@
import Data.Text.Lazy.Builder (toLazyText)
import Data.Aeson.Encode (encodeToTextBuilder)
#else
-import qualified Data.ByteString.Char8 as S8
+import Data.Attoparsec.Number
#endif
import Prelude hiding (null)
@@ -88,8 +89,13 @@
| otherwise = EventScalar (encodeUtf8 s) StrTag PlainNoTag Nothing
-- Use aeson's implementation which gets rid of annoying decimal points
+#if MIN_VERSION_aeson(0, 7, 0)
scientific :: Scientific -> YamlBuilder
scientific n = YamlBuilder (EventScalar (TE.encodeUtf8 $ TL.toStrict $ toLazyText $ encodeToTextBuilder (Number n)) IntTag PlainNoTag Nothing :)
+#else
+scientific :: Number -> YamlBuilder
+scientific n = YamlBuilder (EventScalar (S8.pack $ show n) IntTag PlainNoTag Nothing :)
+#endif
{-# DEPRECATED number "Use scientific" #-}
#if MIN_VERSION_aeson(0,7,0)
@@ -97,7 +103,7 @@
number = scientific
#else
number :: Number -> YamlBuilder
-number n rest = YamlBuilder (EventScalar (S8.pack $ show n) IntTag PlainNoTag Nothing :)
+number n = YamlBuilder (EventScalar (S8.pack $ show n) IntTag PlainNoTag Nothing :)
#endif
bool :: Bool -> YamlBuilder
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.14/Data/Yaml/Internal.hs new/yaml-0.8.15.1/Data/Yaml/Internal.hs
--- old/yaml-0.8.14/Data/Yaml/Internal.hs 2015-08-30 08:11:27.000000000 +0200
+++ new/yaml-0.8.15.1/Data/Yaml/Internal.hs 2015-09-06 10:27:33.000000000 +0200
@@ -19,7 +19,6 @@
import Text.Libyaml hiding (encode, decode, encodeFile, decodeFile)
import Data.ByteString (ByteString)
import qualified Data.Map as Map
-import Data.Maybe (isNothing)
import Control.Exception
import Control.Exception.Enclosed
import Control.Monad.Trans.State
@@ -37,10 +36,11 @@
import Data.Text.Encoding.Error (lenientDecode)
import qualified Data.HashMap.Strict as M
import Data.Typeable
-import Data.Text.Read
#if MIN_VERSION_aeson(0, 7, 0)
-import Data.Scientific (fromFloatDigits)
+import qualified Data.Attoparsec.Text as Atto
+import Data.Scientific (Scientific)
#else
+import Data.Text.Read
import Data.Attoparsec.Number
#endif
import Control.Monad.Trans.Resource (ResourceT, runResourceT)
@@ -162,8 +162,7 @@
| any (t `isLike`) ["y", "yes", "on", "true"] = Bool True
| any (t `isLike`) ["n", "no", "off", "false"] = Bool False
#if MIN_VERSION_aeson(0, 7, 0)
- | Right (x, "") <- signed decimal t = Number $ fromIntegral (x :: Integer)
- | Right (x, "") <- double t = Number $ fromFloatDigits x
+ | Right x <- textToScientific t = Number x
#else
| Right (x, "") <- signed decimal t = Number $ I x
| Right (x, "") <- double t = Number $ D x
@@ -172,6 +171,10 @@
where x `isLike` ref = x `elem` [ref, T.toUpper ref, titleCased]
where titleCased = toUpper (T.head ref) `T.cons` T.tail ref
+#if MIN_VERSION_aeson(0, 7, 0)
+textToScientific :: Text -> Either String Scientific
+textToScientific = Atto.parseOnly (Atto.scientific <* Atto.endOfInput)
+#endif
parseO :: C.Sink Event Parse Value
parseO = do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.14/Data/Yaml/Pretty.hs new/yaml-0.8.15.1/Data/Yaml/Pretty.hs
--- old/yaml-0.8.14/Data/Yaml/Pretty.hs 2015-08-30 08:11:27.000000000 +0200
+++ new/yaml-0.8.15.1/Data/Yaml/Pretty.hs 2015-09-06 10:27:33.000000000 +0200
@@ -48,7 +48,7 @@
go (Array a) = array (fmap go $ V.toList a)
go Null = null
go (String s) = string s
- go (Number n) = number n
+ go (Number n) = scientific n
go (Bool b) = bool b
-- | Configurable 'encode'.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.14/Data/Yaml.hs new/yaml-0.8.15.1/Data/Yaml.hs
--- old/yaml-0.8.14/Data/Yaml.hs 2015-08-30 08:11:27.000000000 +0200
+++ new/yaml-0.8.15.1/Data/Yaml.hs 2015-09-06 10:27:33.000000000 +0200
@@ -68,8 +68,6 @@
import qualified Data.Conduit as C
import qualified Data.Conduit.List as CL
import qualified Data.Vector as V
-import Data.Text (Text)
-import qualified Data.Text as T
import Data.Text.Encoding (encodeUtf8)
import qualified Data.HashMap.Strict as M
import qualified Data.HashSet as HashSet
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.14/test/Data/YamlSpec.hs new/yaml-0.8.15.1/test/Data/YamlSpec.hs
--- old/yaml-0.8.14/test/Data/YamlSpec.hs 2015-08-30 08:11:27.000000000 +0200
+++ new/yaml-0.8.15.1/test/Data/YamlSpec.hs 2015-09-06 10:27:33.000000000 +0200
@@ -148,6 +148,10 @@
it "serialization of +123 #64" $ do
D.decode (D.encode ("+123" :: String)) `shouldBe` Just ("+123" :: String)
+#if MIN_VERSION_aeson(0, 7, 0)
+ it "preserves Scientific precision" casePreservesScientificPrecision
+#endif
+
specialStrings :: [T.Text]
specialStrings =
@@ -465,3 +469,22 @@
])
where
src = "---\na:\n &id5 value: 1.0\nb:\n *id5: 1.2"
+
+#if MIN_VERSION_aeson(0, 7, 0)
+-- | We cannot guarantee this before aeson started using 'Scientific'.
+casePreservesScientificPrecision :: Assertion
+casePreservesScientificPrecision = do
+ D.decodeEither "x: 1e-100000" @?= Right (object
+ [ "x" .= D.Number (read "1e-100000") ])
+ -- Note that this ought to work also without 'Scientific', given
+ -- that @read (show "9.78159610558926e-5") == 9.78159610558926e-5@.
+ -- However, it didn't work (and still doesn't work with aeson < 0.7)
+ -- for two reasons:
+ --
+ -- * We use 'Data.Text.Read.double', which is not as accurate as it
+ -- can be;
+ -- * Even if we used 'Data.Text.Read.rational' we would not get good
+ -- results, because of https://github.com/bos/text/issues/34.
+ D.decodeEither "x: 9.78159610558926e-5" @?= Right (object
+ [ "x" .= D.Number (read "9.78159610558926e-5") ])
+#endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yaml-0.8.14/yaml.cabal new/yaml-0.8.15.1/yaml.cabal
--- old/yaml-0.8.14/yaml.cabal 2015-08-30 08:11:27.000000000 +0200
+++ new/yaml-0.8.15.1/yaml.cabal 2015-09-06 10:27:33.000000000 +0200
@@ -1,5 +1,5 @@
name: yaml
-version: 0.8.14
+version: 0.8.15.1
license: BSD3
license-file: LICENSE
author: Michael Snoyman