packages feed

fmt 0.6.1.2 → 0.6.2.0

raw patch · 9 files changed

+89/−56 lines, 9 filesdep ~formattingdep ~hspecnew-uploaderPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: formatting, hspec

API changes (from Hackage documentation)

- Fmt.Internal.Core: instance (a Data.Type.Equality.~ ()) => Fmt.Internal.Core.FromBuilder (GHC.Types.IO a)
- Fmt.Internal.Core: instance (a Data.Type.Equality.~ GHC.Types.Char) => Fmt.Internal.Core.FromBuilder [a]
+ Fmt.Internal.Core: instance (a GHC.Types.~ ()) => Fmt.Internal.Core.FromBuilder (GHC.Types.IO a)
+ Fmt.Internal.Core: instance (a GHC.Types.~ GHC.Types.Char) => Fmt.Internal.Core.FromBuilder [a]
- Fmt: (|++||) :: (Show a, FromBuilder b) => a -> Builder -> b
+ Fmt: (|++||) :: (Buildable a, FromBuilder b) => a -> Builder -> b
- Fmt: (||++|) :: (Buildable a, FromBuilder b) => a -> Builder -> b
+ Fmt: (||++|) :: (Show a, FromBuilder b) => a -> Builder -> b
- Fmt.Internal.Core: (|++||) :: (Show a, FromBuilder b) => a -> Builder -> b
+ Fmt.Internal.Core: (|++||) :: (Buildable a, FromBuilder b) => a -> Builder -> b
- Fmt.Internal.Core: (||++|) :: (Buildable a, FromBuilder b) => a -> Builder -> b
+ Fmt.Internal.Core: (||++|) :: (Show a, FromBuilder b) => a -> Builder -> b
- Fmt.Internal.Core: infixr 1 |++||
+ Fmt.Internal.Core: infixr 1 ||++|

Files

CHANGELOG.md view
@@ -1,3 +1,13 @@+# 0.6.2.0++* Cleared `hspec` upper bound+* Qualified all Data.List imports+* Fixed tests to work with newer (>=0.4) neat-interpolation (#30)+* Adjusted lower bounds of formatting dependency to avoid unsigned 0+  issues (#31)+* fixed floatF handling of negative numbers (#36)+* unconfused ``||++|`` and ``|++||`` (#29)+ # 0.6.1.2  * Bumped the `hspec` upper bound.
fmt.cabal view
@@ -1,5 +1,5 @@ name:                fmt-version:             0.6.1.2+version:             0.6.2.0 synopsis:            A new formatting library description:   A new formatting library that tries to be simple to understand while still@@ -37,13 +37,13 @@     conversion. There are some convenience formatters which aren't present in     @formatting@ (like ones for formatting maps, lists, converting to base64,     etc). Some find the operator syntax annoying, while others like it.-homepage:            http://github.com/aelve/fmt-bug-reports:         http://github.com/aelve/fmt/issues+homepage:            http://github.com/cdornan/fmt+bug-reports:         http://github.com/cdornan/fmt/issues license:             BSD3 license-file:        LICENSE author:              Artyom Kazak <yom@artyom.me>,                      Dmitry Kovanikov <kovanikov@gmail.com>-maintainer:          yom@artyom.me+maintainer:          Chris Dornan <chris@chrisdornan.com> -- copyright: category:            Text tested-with:@@ -52,6 +52,8 @@   GHC == 8.2.2   GHC == 8.4.4   GHC == 8.6.4+  GHC == 8.6.5+  GHC == 8.10.4 build-type:          Simple extra-source-files:  CHANGELOG.md                      tests/doctest-config.json@@ -59,7 +61,7 @@  source-repository head   type:                git-  location:            git://github.com/aelve/fmt.git+  location:            git://github.com/cdornan/fmt.git  library   exposed-modules:     Fmt@@ -77,7 +79,7 @@                        bytestring,                        call-stack,                        containers,-                       formatting >= 6.3.4,+                       formatting >= 7.0.0,                        microlens >= 0.3,                        text,                        time,@@ -99,7 +101,7 @@                      , call-stack                      , containers                      , fmt-                     , hspec >= 2.2 && < 2.8+                     , hspec >= 2.2                      , neat-interpolation                      , text                      , vector
lib/Fmt/Internal.hs view
@@ -72,7 +72,9 @@   hexF = fromLazyText . TL.decodeLatin1 . BB.toLazyByteString . BB.lazyByteStringHex  instance {-# OVERLAPPABLE #-} Integral a => FormatAsHex a where-  hexF = F.hex+  hexF i = sgn <> F.hex (abs i)+    where+      sgn = if i<0 then "-" else ""  ---------------------------------------------------------------------------- -- Base64
lib/Fmt/Internal/Core.hs view
@@ -96,13 +96,13 @@ (||++||) a rest = show a |+ rest {-# INLINE (||++||) #-} -(||++|) :: (Buildable a, FromBuilder b) => a -> Builder -> b-(||++|) a rest = a |++| rest-{-# INLINE (||++|) #-}--(|++||) :: (Show a, FromBuilder b) => a -> Builder -> b-(|++||) a rest = a ||++|| rest+(|++||) :: (Buildable a, FromBuilder b) => a -> Builder -> b+(|++||) a rest = a |++| rest {-# INLINE (|++||) #-}++(||++|) :: (Show a, FromBuilder b) => a -> Builder -> b+(||++|) a rest = a ||++|| rest+{-# INLINE (||++|) #-}  infixr 1 |++| infixr 1 ||++||
lib/Fmt/Internal/Formatters.hs view
@@ -9,7 +9,7 @@   -- Generic useful things-import Data.List+import Data.List (intersperse) import Lens.Micro #if __GLASGOW_HASKELL__ < 804 import Data.Monoid ((<>))
lib/Fmt/Internal/Generic.hs view
@@ -21,7 +21,7 @@ import Data.List.NonEmpty (NonEmpty) #endif -import Data.List+import Data.List as L import Data.Text.Lazy.Builder hiding (fromString) import GHC.Generics import Formatting.Buildable
lib/Fmt/Internal/Numeric.hs view
@@ -69,13 +69,16 @@ Numbers smaller than 1e-6 or bigger-or-equal to 1e21 will be displayed using scientific notation: +>>> listF' floatF [-1.2,-12.2]+"[-1.2, -12.2]" >>> listF' floatF [1e-6,9e-7] "[0.000001, 9.0e-7]" >>> listF' floatF [9e20,1e21] "[900000000000000000000.0, 1.0e21]" -} floatF :: Real a => a -> Builder-floatF a | d < 1e-6 || d >= 1e21 = build $ showEFloat Nothing d ""+floatF a | d < 0                 = "-" <> floatF (-d)+         | d < 1e-6 || d >= 1e21 = build $ showEFloat Nothing d ""          | otherwise             = build $ showFFloat Nothing d ""   where d = realToFrac a :: Double 
lib/Fmt/Time.hs view
@@ -122,7 +122,11 @@   import           Data.List               (find)++#if !MIN_VERSION_base(4,9,0) import           Data.Monoid             ((<>))+#endif+ import           Data.Text               (Text) import qualified Data.Text               as T import           Formatting.Buildable    (build)
tests/Main.hs view
@@ -2,13 +2,16 @@ {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE CPP #-}   module Main where   -- Monoid+#if __GLASGOW_HASKELL__ < 804 import Data.Monoid ((<>))+#endif -- Text import Data.Text (Text) import qualified Data.Text as T@@ -277,43 +280,43 @@         blockListF ([] :: [Int]) ==#> "[]\n"      nullElements = it "null elements" $ do-        blockListF ([""] :: [Text]) ==#> [text|+        blockListF ([""] :: [Text]) ==$> [text|           -           |]-        blockListF (["",""] :: [Text]) ==#> [text|+        blockListF (["",""] :: [Text]) ==$> [text|           -           -           |]-        blockListF (["","a",""] :: [Text]) ==#> [text|+        blockListF (["","a",""] :: [Text]) ==$> [text|           -           - a           -           |]      singleLineElements = it "single-line elements" $ do-        blockListF (["a"] :: [Text]) ==#> [text|+        blockListF (["a"] :: [Text]) ==$> [text|           - a           |]-        blockListF (["a","b"] :: [Text]) ==#> [text|+        blockListF (["a","b"] :: [Text]) ==$> [text|           -_a           -_b           |]-        blockListF (["a","b","ccc"] :: [Text]) ==#> [text|+        blockListF (["a","b","ccc"] :: [Text]) ==$> [text|           - a           - b           - ccc           |]      multiLineElements = it "multi-line elements" $ do-        blockListF (["a\nx"] :: [Text]) ==#> [text|+        blockListF (["a\nx"] :: [Text]) ==$> [text|           - a             x           |]-        blockListF (["a\n x"] :: [Text]) ==#> [text|+        blockListF (["a\n x"] :: [Text]) ==$> [text|           - a              x           |]-        blockListF (["a\n x"," b\nxx\ny y ","c\n\n"] :: [Text]) ==#> [text|+        blockListF (["a\n x"," b\nxx\ny y ","c\n\n"] :: [Text]) ==$> [text|           - a              x           -  b@@ -324,17 +327,17 @@           |]      mixed = it "mix of single-line and multi-line" $ do-        blockListF (["a\nx","b"] :: [Text]) ==#> [text|+        blockListF (["a\nx","b"] :: [Text]) ==$> [text|           - a             x           - b           |]-        blockListF (["a\nx","b\n"] :: [Text]) ==#> [text|+        blockListF (["a\nx","b\n"] :: [Text]) ==$> [text|           - a             x           - b           |]-        blockListF (["a"," b\nxx\ny y ","c\n\n"] :: [Text]) ==#> [text|+        blockListF (["a"," b\nxx\ny y ","c\n\n"] :: [Text]) ==$> [text|           - a           -  b             xx@@ -356,18 +359,18 @@         jsonListF ([] :: [Int]) ==#> "[]\n"      nullElements = it "null elements" $ do-        jsonListF ([""] :: [Text]) ==#> [text|+        jsonListF ([""] :: [Text]) ==$> [text|           [            ]           |]-        jsonListF (["",""] :: [Text]) ==#> [text|+        jsonListF (["",""] :: [Text]) ==$> [text|           [            ,           ]           |]-        jsonListF (["","a",""] :: [Text]) ==#> [text|+        jsonListF (["","a",""] :: [Text]) ==$> [text|           [            , a@@ -376,18 +379,18 @@           |]      singleLineElements = it "single-line elements" $ do-        jsonListF (["a"] :: [Text]) ==#> [text|+        jsonListF (["a"] :: [Text]) ==$> [text|           [             a           ]           |]-        jsonListF (["a","b"] :: [Text]) ==#> [text|+        jsonListF (["a","b"] :: [Text]) ==$> [text|           [             a           , b           ]           |]-        jsonListF (["a","b","ccc"] :: [Text]) ==#> [text|+        jsonListF (["a","b","ccc"] :: [Text]) ==$> [text|           [             a           , b@@ -396,19 +399,19 @@           |]      multiLineElements = it "multi-line elements" $ do-        jsonListF (["a\nx"] :: [Text]) ==#> [text|+        jsonListF (["a\nx"] :: [Text]) ==$> [text|           [             a             x           ]           |]-        jsonListF (["a\n x"] :: [Text]) ==#> [text|+        jsonListF (["a\n x"] :: [Text]) ==$> [text|           [             a              x           ]           |]-        jsonListF (["a\n x"," b\nxx\ny y ","c\n\n"] :: [Text]) ==#> [text|+        jsonListF (["a\n x"," b\nxx\ny y ","c\n\n"] :: [Text]) ==$> [text|           [             a              x@@ -421,21 +424,21 @@           |]      mixed = it "mix of single-line and multi-line" $ do-        jsonListF (["a\nx","b"] :: [Text]) ==#> [text|+        jsonListF (["a\nx","b"] :: [Text]) ==$> [text|           [             a             x           , b           ]           |]-        jsonListF (["a\nx","b\n"] :: [Text]) ==#> [text|+        jsonListF (["a\nx","b\n"] :: [Text]) ==$> [text|           [             a             x           , b           ]           |]-        jsonListF (["a"," b\nxx\ny y ","c\n\n"] :: [Text]) ==#> [text|+        jsonListF (["a"," b\nxx\ny y ","c\n\n"] :: [Text]) ==$> [text|           [             a           ,  b@@ -477,7 +480,7 @@     blockMapF ([("hi", ""),                 ("foo"," a\n  b"),                 ("bar","a"),-                ("baz","a\ng")] :: [(Text, Text)]) ==#> [text|+                ("baz","a\ng")] :: [(Text, Text)]) ==$> [text|       hi:       foo:          a@@ -496,7 +499,7 @@     jsonMapF ([("hi", ""),                ("foo"," a\n  b"),                ("bar","a"),-               ("baz","a\ng")] :: [(Text, Text)]) ==#> [text|+               ("baz","a\ng")] :: [(Text, Text)]) ==$> [text|       {         hi:       , foo:@@ -559,40 +562,40 @@   where     allNonEmpty = describe "all non-empty" $ do       it "1 element (2 lines)" $ do-          tupleF ["a\nx" :: Builder] ==#> [text|+          tupleF ["a\nx" :: Builder] ==$> [text|             ( a               x )             |]-          tupleF ["a\n x" :: Builder] ==#> [text|+          tupleF ["a\n x" :: Builder] ==$> [text|             ( a                x )             |]-          tupleF [" a\nx\n" :: Builder] ==#> [text|+          tupleF [" a\nx\n" :: Builder] ==$> [text|             (  a               x )             |]       it "1 element (3 lines)" $ do-          tupleF ["a\nb\nc" :: Builder] ==#> [text|+          tupleF ["a\nb\nc" :: Builder] ==$> [text|             ( a               b               c )             |]       it "2 elements (1 line + 2 lines)" $ do-          tupleF ["a", "b\nc" :: Builder] ==#> [text|+          tupleF ["a", "b\nc" :: Builder] ==$> [text|             ( a             ,               b               c )             |]       it "2 elements (2 lines + 1 line)" $ do-          tupleF ["a\nb", "c" :: Builder] ==#> [text|+          tupleF ["a\nb", "c" :: Builder] ==$> [text|             ( a               b             ,               c )             |]       it "3 elements (each has 2 lines)" $ do-          tupleF ["a\nb", "c\nd", "e\nf" :: Builder] ==#> [text|+          tupleF ["a\nb", "c\nd", "e\nf" :: Builder] ==$> [text|             ( a               b             ,@@ -605,21 +608,21 @@      someEmpty = describe "some empty" $ do       it "2 elements (0 + 2)" $ do-          tupleF ["", "a\nb" :: Builder] ==#> [text|+          tupleF ["", "a\nb" :: Builder] ==$> [text|             (             ,               a               b )             |]       it "2 elements (2 + 0)" $ do-          tupleF ["a\nb", "" :: Builder] ==#> [text|+          tupleF ["a\nb", "" :: Builder] ==$> [text|             ( a               b             ,               )             |]       it "3 elements (0 + 2 + 0)" $ do-          tupleF ["", "a\nb", "" :: Builder] ==#> [text|+          tupleF ["", "a\nb", "" :: Builder] ==$> [text|             (             ,               a@@ -628,7 +631,7 @@               )             |]       it "3 elements (2 + 0 + 2)" $ do-          tupleF ["a\nb", "", "c\nd" :: Builder] ==#> [text|+          tupleF ["a\nb", "", "c\nd" :: Builder] ==$> [text|             ( a               b             ,@@ -637,7 +640,7 @@               d )             |]       it "4 elements (2 + 0 + 0 + 2)" $ do-          tupleF ["a\nb", "", "", "c\nd" :: Builder] ==#> [text|+          tupleF ["a\nb", "", "", "c\nd" :: Builder] ==$> [text|             ( a               b             ,@@ -678,7 +681,7 @@       genericF (Foo n) ==#> "<Foo: 25>"       genericF (Bar (n-1) (n+1)) ==#> "<Bar: 24, 26>"     it "records" $ do-      genericF (Qux 1 True "hi") ==#> [text|+      genericF (Qux 1 True "hi") ==$> [text|         Qux:           q1: 1           q2: True@@ -716,6 +719,15 @@  (==%>) :: HasCallStack => Text -> Text -> Expectation (==%>) = shouldBe++-- the RHS has @neat-interpolation@ string for which later versions (>=0.4) are discarding the final+-- newline; we must detect when it is doing so and restore the newline+(==$>) :: HasCallStack => Builder -> Text -> Expectation+(==$>) a b0 = a ==#> b+  where+    b = case T.last b0 == '\n' of+      True  -> b0+      False -> b0 <> "\n"  (==#>) :: HasCallStack => Builder -> Text -> Expectation (==#>) a b = a `shouldBe` build (T.replace "_" " " b)