formatting 6.3.0 → 6.3.1
raw patch · 6 files changed
+34/−6 lines, 6 filesdep +semigroupsdep ~basedep ~integer-gmpPVP ok
version bump matches the API change (PVP)
Dependencies added: semigroups
Dependency ranges changed: base, integer-gmp
API changes (from Hackage documentation)
+ Formatting.Internal: instance Data.Semigroup.Semigroup (Formatting.Internal.Format r (a -> r))
Files
- formatting.cabal +4/−2
- src/Data/Text/Format/Functions.hs +6/−0
- src/Data/Text/Format/Int.hs +3/−0
- src/Formatting/Buildable.hs +3/−0
- src/Formatting/Internal.hs +9/−2
- test/Spec.hs +9/−2
formatting.cabal view
@@ -1,5 +1,5 @@ name: formatting-version: 6.3.0+version: 6.3.1 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@@ -42,7 +42,9 @@ transformers, bytestring, integer-gmp >= 0.2-+ if !impl(ghc >= 8.0)+ build-depends:+ semigroups >= 0.11 && < 0.19 hs-source-dirs: src ghc-options: -O2 cpp-options: -DINTEGER_GMP
src/Data/Text/Format/Functions.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE MagicHash #-}+{-# LANGUAGE CPP #-} -- | -- Module : Data.Text.Format.Functions@@ -19,7 +20,12 @@ import Data.Monoid (mappend) import Data.Text.Lazy.Builder (Builder)+#if MIN_VERSION_base(4,11,0)+import Prelude hiding ((<>))+import GHC.Base hiding ((<>))+#else import GHC.Base+#endif -- | Unsafe conversion for decimal digits. {-# INLINE i2d #-}
src/Data/Text/Format/Int.hs view
@@ -17,6 +17,9 @@ , 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)
src/Formatting/Buildable.hs view
@@ -20,6 +20,9 @@ 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)
src/Formatting/Internal.hs view
@@ -1,12 +1,16 @@ {-# 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 Data.String import qualified Data.Text as S (Text) import Data.Text.Lazy (Text)@@ -50,10 +54,13 @@ -- | Useful instance for applying two formatters to the same input -- argument. For example: @format (year <> "/" % month) now@ will -- yield @"2015/01"@.-instance Monoid (Format r (a -> r)) where- mappend m n =+instance Sem.Semigroup (Format r (a -> r)) where+ (<>) 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) -- | Useful instance for writing format string. With this you can
test/Spec.hs view
@@ -37,5 +37,12 @@ "https://github.com/bos/text-format/issues/18" (do it "build (minBound :: Int)"- (shouldBe (format build (minBound :: Int64))- "-9223372036854775808")))+ (shouldBe+ (format build (minBound :: Int64))+ "-9223372036854775808")))+ describe+ "Floating point"+ (do it "Fixed" (shouldBe (format (fixed 4) (12.123456 :: Double)) "12.1235")+ it+ "Variable"+ (shouldBe (format float (12.123456 :: Double)) "12.123456"))