packages feed

formatting 6.3.1 → 6.3.2

raw patch · 8 files changed

+50/−41 lines, 8 filesdep ~semigroupsPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: semigroups

API changes (from Hackage documentation)

- Formatting.Formatters: int :: (Integral a, Buildable a) => Format r (a -> r)
+ Formatting.Formatters: int :: (Buildable a) => Format r (a -> r)
- Formatting.ShortFormatters: d :: (Integral a, Buildable a) => Format r (a -> r)
+ Formatting.ShortFormatters: d :: (Buildable a) => Format r (a -> r)

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+6.3.1++* Proper GHC 7.10 -> GHC 8.4 support+ 6.3.0  * Folded the `text-format` package into this package, removed the
formatting.cabal view
@@ -1,5 +1,5 @@ name:                formatting-version:             6.3.1+version:             6.3.2 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. license:             BSD3@@ -41,10 +41,9 @@     text >= 0.11.0.8,     transformers,     bytestring,-    integer-gmp >= 0.2-  if !impl(ghc >= 8.0)-    build-depends:-      semigroups >= 0.11 && < 0.19+    integer-gmp >= 0.2,+    semigroups+   hs-source-dirs:    src   ghc-options:       -O2   cpp-options: -DINTEGER_GMP@@ -53,7 +52,7 @@   type:                exitcode-stdio-1.0   hs-source-dirs:      test   main-is:             Spec.hs-  build-depends:       base, formatting, hspec+  build-depends:       base, formatting, hspec, semigroups   ghc-options:         -Wall -threaded -rtsopts -with-rtsopts=-N  source-repository head
src/Data/Text/Format/Int.hs view
@@ -17,12 +17,10 @@     , minus     ) where -#if MIN_VERSION_base(4,11,0)-import Prelude hiding ((<>))-#endif import Data.Int (Int8, Int16, Int32, Int64) import Data.Monoid (mempty)-import Data.Text.Format.Functions ((<>), i2d)+import Data.Text.Format.Functions (i2d)+import qualified Data.Text.Format.Functions as F ((<>)) import Data.Text.Lazy.Builder import Data.Word (Word, Word8, Word16, Word32, Word64) import GHC.Base (quotInt, remInt)@@ -59,12 +57,12 @@     | i == minBound =         -- special case, since (-i) would not be representable assuming two's         -- compliment:-        minus <> integer 10 (negate $ fromIntegral i)-    | i < 0     = minus <> go (-i)+        minus F.<> integer 10 (negate $ fromIntegral i)+    | i < 0     = minus F.<> go (-i)     | otherwise = go i   where     go n | n < 10    = digit n-         | otherwise = go (n `quot` 10) <> digit (n `rem` 10)+         | otherwise = go (n `quot` 10) F.<> digit (n `rem` 10) {-# NOINLINE[0] decimal #-}  hexadecimal :: Integral a => a -> Builder@@ -80,11 +78,11 @@ {-# SPECIALIZE hexadecimal :: Word64 -> Builder #-} {-# RULES "hexadecimal/Integer" hexadecimal = integer 16 :: Integer -> Builder #-} hexadecimal i-    | i < 0     = minus <> go (-i)+    | i < 0     = minus F.<> go (-i)     | otherwise = go i   where     go n | n < 16    = hexDigit n-         | otherwise = go (n `quot` 16) <> hexDigit (n `rem` 16)+         | otherwise = go (n `quot` 16) F.<> hexDigit (n `rem` 16) {-# NOINLINE[0] hexadecimal #-}  digit :: Integral a => a -> Builder@@ -110,7 +108,7 @@ integer 10 (S# i#) = decimal (I# i#) integer 16 (S# i#) = hexadecimal (I# i#) integer base i-    | i < 0     = minus <> go (-i)+    | i < 0     = minus F.<> go (-i)     | otherwise = go i   where     go n | n < maxInt = int (fromInteger n)@@ -145,14 +143,14 @@      putH (n:ns) = case n `quotRemInteger` maxInt of                     PAIR(x,y)-                        | q > 0     -> int q <> pblock r <> putB ns-                        | otherwise -> int r <> putB ns+                        | q > 0     -> int q F.<> pblock r F.<> putB ns+                        | otherwise -> int r F.<> putB ns                         where q = fromInteger x                               r = fromInteger y     putH _ = error "putH: the impossible happened"      putB (n:ns) = case n `quotRemInteger` maxInt of-                    PAIR(x,y) -> pblock q <> pblock r <> putB ns+                    PAIR(x,y) -> pblock q F.<> pblock r F.<> putB ns                         where q = fromInteger x                               r = fromInteger y     putB _ = mempty@@ -161,6 +159,6 @@       where         loop !d !n             | d == 1    = digit n-            | otherwise = loop (d-1) q <> digit r+            | otherwise = loop (d-1) q F.<> digit r             where q = n `quotInt` base                   r = n `remInt` base
src/Formatting/Buildable.hs view
@@ -20,15 +20,12 @@ import qualified Data.ByteString.Lazy as L import           Data.Void (Void, absurd) #endif-#if MIN_VERSION_base(4,11,0)-import Prelude hiding ((<>))-#endif  import           Data.Monoid (mempty) import           Data.Int (Int8, Int16, Int32, Int64) import           Data.Fixed (Fixed, HasResolution, showFixed) import           Data.Ratio (Ratio, denominator, numerator)-import           Data.Text.Format.Functions ((<>))+import qualified Data.Text.Format.Functions as F ((<>)) import           Data.Text.Format.Int (decimal, hexadecimal, integer) import           Data.Text.Format.Types (Hex(..), Shown(..)) import           Data.Text.Lazy.Builder@@ -125,7 +122,7 @@  instance (Integral a, Buildable a) => Buildable (Ratio a) where     {-# SPECIALIZE instance Buildable (Ratio Integer) #-}-    build a = build (numerator a) <> singleton '/' <> build (denominator a)+    build a = build (numerator a) F.<> singleton '/' F.<> build (denominator a)  instance Buildable Float where     build = fromText . T.decodeUtf8 . L.toStrict . L.toLazyByteString . L.floatDec@@ -181,10 +178,10 @@     {-# INLINE build #-}  instance Buildable IntPtr where-    build p = fromText "0x" <> hexadecimal p+    build p = fromText "0x" F.<> hexadecimal p  instance Buildable WordPtr where-    build p = fromText "0x" <> hexadecimal p+    build p = fromText "0x" F.<> hexadecimal p  instance Buildable (Ptr a) where     build = build . ptrToWordPtr
src/Formatting/Formatters.hs view
@@ -57,7 +57,7 @@ import           Formatting.Internal  import           Data.Char (chr, ord)-import           Data.Monoid+import           Data.Monoid ((<>)) import           Data.Scientific import qualified Data.Text as S import qualified Data.Text as T@@ -108,7 +108,7 @@ build = later B.build  -- | Render an integral e.g. 123 -> \"123\", 0 -> \"0\".-int :: (Integral a, Buildable a) => Format r (a -> r)+int :: (Buildable a) => Format r (a -> r) int = later B.build  -- | Render some floating point with the usual notation, e.g. 123.32 => \"123.32\"
src/Formatting/Internal.hs view
@@ -1,16 +1,13 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE CPP #-}  -- | Internal format starters.  module Formatting.Internal where  import           Control.Category (Category(..))-import qualified Data.Semigroup as Sem-#if !MIN_VERSION_base(4,11,0) import           Data.Monoid-#endif+import qualified Data.Semigroup import           Data.String import qualified Data.Text as S (Text) import           Data.Text.Lazy (Text)@@ -54,14 +51,14 @@ -- | Useful instance for applying two formatters to the same input -- argument. For example: @format (year <> "/" % month) now@ will -- yield @"2015/01"@.-instance Sem.Semigroup (Format r (a -> r)) where-  (<>) m n =+instance Monoid (Format r (a -> r)) where+  mappend m n =     Format (\k a ->               runFormat m (\b1 -> runFormat n (\b2 -> k (b1 <> b2)) a) a)--instance Monoid (Format r (a -> r)) where-  mappend = (<>)   mempty = Format (\k _ -> k mempty)++instance Data.Semigroup.Semigroup (Format r (a -> r)) where+  (<>) = mappend  -- | Useful instance for writing format string. With this you can -- write @"Foo"@ instead of @now "Foo!"@.
src/Formatting/ShortFormatters.hs view
@@ -30,7 +30,7 @@ t = later T.fromLazyText  -- | Render an integral e.g. 123 -> \"123\", 0 -> \"0\".-d :: (Integral a, Buildable a) => Format r (a -> r)+d :: (Buildable a) => Format r (a -> r) d = int  -- | Render an integer using binary notation. (No leading 0b is
test/Spec.hs view
@@ -1,6 +1,8 @@ {-# LANGUAGE OverloadedStrings #-}  import Data.Int+import qualified Data.Monoid+import qualified Data.Semigroup import Formatting as F import Test.Hspec @@ -11,7 +13,14 @@ spec = do   describe     "Regression tests"-    (do describe+    (do describe "https://github.com/chrisdone/formatting/issues/36"+                 (do it "format (later id <> later id) \"x\""+                        (shouldBe (format (later id Data.Monoid.<> later id) "x")+                                  "xx")+                     it "format (later id <> later id) \"x\""+                        (shouldBe (format (later id Data.Semigroup.<> later id) "x")+                                  "xx"))+        describe           "https://github.com/chrisdone/formatting/issues/31"           (do it                 "10^6-1"@@ -39,7 +48,12 @@                 "build (minBound :: Int)"                 (shouldBe                    (format build (minBound :: Int64))-                   "-9223372036854775808")))+                   "-9223372036854775808"))+        it+          "build (maxBound :: Int)"+          (shouldBe+             (format build (maxBound :: Int))+             "9223372036854775807"))   describe     "Floating point"     (do it "Fixed" (shouldBe (format (fixed 4) (12.123456 :: Double)) "12.1235")