packages feed

formatting 7.1.2 → 7.1.3

raw patch · 4 files changed

+29/−4 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+7.1.3++* Fix the GHCJS build by not using `double-conversion`, as it relies on a native C library which obviously isn't available in GHCJS (it is still used in native builds).+ 7.1.2  * Removed direct dependency on integer-gmp, instead using very similar code from the `text` package. This changed the implementation of `build` for `Integer`, which results in better performance in some cases, and no performance degradation. See the benchmarking reports in bench/reports for more details.
README.md view
@@ -534,7 +534,7 @@ From within your `nix-shell`, run `cabal bench`.  To build the html benchmarking reports, run `cabal bench --benchmark-option=-obench/reports/7.2.0.html > bench/reports/7.2.0.txt`, replacing '7.2.0' with the current version.-This will output the file `bench.html` which you can open in a browser.+This will output the file `bench/reports/7.2.0.html` which you can open in a browser, and bench/reports/7.2.0.txt which you can view in a terminal or text editor.  The benchmarks are in `bench/bench.hs`. 
formatting.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.4 name:                formatting-version:             7.1.2+version:             7.1.3 synopsis:            Combinator-based type-safe formatting (like printf() or FORMAT) description:         Combinator-based type-safe formatting (like printf() or FORMAT), modelled from the HoleyMonoids package.                      .@@ -54,11 +54,13 @@   hs-source-dirs:    src   build-depends:     clock >= 0.4,-    double-conversion ^>= 2.0.2.0,     old-locale,     scientific >= 0.3.0.0,     time >= 1.5,     transformers,+  if !impl(ghcjs)+    build-depends:+      double-conversion ^>= 2.0.2.0,   exposed-modules:     Formatting     Formatting.Formatters
src/Data/Text/Format.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE RelaxedPolyRec #-}+{-# LANGUAGE CPP #-}  -- | -- Module      : Data.Text.Format@@ -23,7 +24,11 @@     , shortest     ) where -import           Data.Double.Conversion.Text+#ifdef ghcjs_HOST_OS+import           Text.Printf+#else+import           Data.Double.Conversion.Text (toFixed, toShortest)+#endif import qualified Formatting.Buildable as B import           Data.Text.Format.Types (Hex(..)) import qualified Data.Text.Lazy as LT@@ -48,13 +53,27 @@          Int       -- ^ Number of digits of precision after the decimal.       -> a -> Builder+#ifdef ghcjs_HOST_OS+fixed decs = fromString . toFixed . realToFrac+  where+    toFixed :: Double -> String+    toFixed = printf ("%f." ++ show decs)+#else fixed decs = fromText . toFixed decs . realToFrac+#endif {-# NOINLINE[0] fixed #-}  -- | Render a floating point number using the smallest number of -- digits that correctly represent it. shortest :: Real a => a -> Builder+#ifdef ghcjs_HOST_OS+shortest = fromString . toShortest . realToFrac+  where+    toShortest :: Double -> String+    toShortest = printf "%f"+#else shortest = fromText . toShortest . realToFrac+#endif {-# INLINE shortest #-}  -- | Render an integer using hexadecimal notation.  (No leading "0x"