packages feed

text-show 3.10.1 → 3.10.2

raw patch · 9 files changed

+152/−17 lines, 9 filesdep ~basedep ~base-compat-batteriesdep ~base-orphans

Dependency ranges changed: base, base-compat-batteries, base-orphans, ghc-boot-th, template-haskell

Files

CHANGELOG.md view
@@ -1,3 +1,9 @@+### 3.10.2 [2023.03.05]+* Allow building with GHC 9.6.+* Add `TextShow` instances for `SomeChar` (if building with `base-4.16` or+  later), as well as `SNat`, `SSymbol`, and `SChar` (if building with+  `base-4.18` or later).+ ### 3.10.1 [2023.02.27] * Support `th-abstraction-0.5.*`. 
src/TextShow/Data/Tuple.hs view
@@ -122,6 +122,10 @@  -- | /Since: 3.9.3/ instance TextShow1 Solo where-    liftShowbPrec sp _ p (Solo x) = showbUnaryWith sp "Solo" p x+# if MIN_VERSION_ghc_prim(0,10,0)+    liftShowbPrec sp _ p (MkSolo x) = showbUnaryWith sp "MkSolo" p x+# else+    liftShowbPrec sp _ p (Solo   x) = showbUnaryWith sp "Solo"   p x+# endif     {-# INLINE liftShowbPrec #-} #endif
src/TextShow/GHC/TypeLits.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-| Module:      TextShow.GHC.TypeLits@@ -14,6 +15,9 @@ module TextShow.GHC.TypeLits () where  import GHC.TypeLits (SomeNat(..), SomeSymbol(..), natVal, symbolVal)+#if MIN_VERSION_base(4,16,0)+import GHC.TypeLits (SomeChar(..), charVal)+#endif  import Prelude () import Prelude.Compat@@ -22,6 +26,15 @@ import TextShow.Data.Char () import TextShow.Data.Integral () +#if MIN_VERSION_base(4,18,0)+import Data.Text.Lazy.Builder (fromString)+import GHC.Show (appPrec, appPrec1)+import GHC.TypeLits ( SNat, SSymbol, SChar+                    , fromSNat, fromSSymbol, fromSChar+                    )+import TextShow.Classes (showbParen)+#endif+ -- | /Since: 2/ instance TextShow SomeNat where     showbPrec p (SomeNat x) = showbPrec p $ natVal x@@ -31,3 +44,36 @@ instance TextShow SomeSymbol where     showb (SomeSymbol x) = showbList $ symbolVal x     {-# INLINE showb #-}++#if MIN_VERSION_base(4,16,0)+-- | /Since: 3.10.1/+instance TextShow SomeChar where+    showbPrec p (SomeChar x) = showbPrec p $ charVal x+    {-# INLINE showbPrec #-}+#endif++#if MIN_VERSION_base(4,18,0)+-- | /Since: 3.10.1/+instance TextShow (SNat n) where+  showbPrec p sn+    = showbParen (p > appPrec)+      ( fromString "SNat @"+     <> showbPrec appPrec1 (fromSNat sn)+      )++-- | /Since: 3.10.1/+instance TextShow (SSymbol s) where+  showbPrec p ss+    = showbParen (p > appPrec)+      ( fromString "SSymbol @"+     <> showbList (fromSSymbol ss)+      )++-- | /Since: 3.10.1/+instance TextShow (SChar c) where+  showbPrec p sc+    = showbParen (p > appPrec)+      ( fromString "SChar @"+     <> showbPrec appPrec1 (fromSChar sc)+      )+#endif
src/TextShow/TH/Internal.hs view
@@ -1069,7 +1069,7 @@ -- | We cannot implement class methods at the term level for @type data@ -- declarations, which only exist at the type level. typeDataError :: Name -> Q a-typeDataError dataName = fail+typeDataError dataName = Monad.fail   . showString "Cannot derive instance for ‘"   . showString (nameBase dataName)   . showString "‘, which is a ‘type data‘ declaration"
tests/Instances/GHC/TypeLits.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE PolyKinds #-} {-# OPTIONS_GHC -fno-warn-orphans #-} @@ -19,7 +20,13 @@ import Prelude.Compat  import Test.QuickCheck (Arbitrary(..), getNonNegative)+import Test.QuickCheck.Instances () +#if MIN_VERSION_base(4,18,0)+import qualified GHC.TypeNats as TN+import Spec.Utils (GArbitrary(..), Some(..))+#endif+ instance Arbitrary SomeNat where     arbitrary = do         nat <- getNonNegative <$> arbitrary@@ -29,3 +36,25 @@  instance Arbitrary SomeSymbol where     arbitrary = someSymbolVal <$> arbitrary++#if MIN_VERSION_base(4,16,0)+instance Arbitrary SomeChar where+    arbitrary = someCharVal <$> arbitrary+#endif++#if MIN_VERSION_base(4,18,0)+instance GArbitrary SNat where+  garbitrary = do+    n <- arbitrary+    TN.withSomeSNat n (pure . Some)++instance GArbitrary SSymbol where+  garbitrary = do+    s <- arbitrary+    withSomeSSymbol s (pure . Some)++instance GArbitrary SChar where+  garbitrary = do+    c <- arbitrary+    withSomeSChar c (pure . Some)+#endif
tests/Spec/Data/IntegralSpec.hs view
@@ -24,8 +24,6 @@ import Test.Hspec (Spec, describe, hspec, parallel)  #if !defined(mingw32_HOST_OS) && MIN_VERSION_text(1,0,0)-import Control.Applicative (liftA2)- import Data.Char (intToDigit)  import Numeric (showIntAtBase)@@ -75,7 +73,7 @@ #if !defined(mingw32_HOST_OS) && MIN_VERSION_text(1,0,0) prop_showIntAtBase :: Gen Expectation prop_showIntAtBase = do-    base <- arbitrary `suchThat` liftA2 (&&) (> 1) (<= 16)+    base <- arbitrary `suchThat` \b -> 1 < b && b <= 16     i    <- getNonNegative <$> arbitrary :: Gen Int     pure $ fromString (showIntAtBase base intToDigit i "") `shouldBe` showbIntAtBase base intToDigit i #endif
tests/Spec/GHC/TypeLitsSpec.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-}  {-|@@ -22,6 +23,9 @@ import Prelude.Compat  import Spec.Utils (matchesTextShowSpec)+#if MIN_VERSION_base(4,18,0)+import Spec.Utils (Some)+#endif  import Test.Hspec (Spec, describe, hspec, parallel) @@ -34,3 +38,15 @@         matchesTextShowSpec (Proxy :: Proxy SomeNat)     describe "SomeSymbol" $         matchesTextShowSpec (Proxy :: Proxy SomeSymbol)+#if MIN_VERSION_base(4,16,0)+    describe "SomeChar" $+        matchesTextShowSpec (Proxy :: Proxy SomeChar)+#endif+#if MIN_VERSION_base(4,18,0)+    describe "Some SNat" $+        matchesTextShowSpec (Proxy :: Proxy (Some SNat))+    describe "Some SSymbol" $+        matchesTextShowSpec (Proxy :: Proxy (Some SSymbol))+    describe "Some SChar" $+        matchesTextShowSpec (Proxy :: Proxy (Some SChar))+#endif
tests/Spec/Utils.hs view
@@ -1,7 +1,14 @@-{-# LANGUAGE CPP                 #-}-{-# LANGUAGE FlexibleContexts    #-}-{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE CPP                   #-}+{-# LANGUAGE FlexibleContexts      #-}+{-# LANGUAGE GADTs                 #-}+{-# LANGUAGE PolyKinds             #-}+{-# LANGUAGE ScopedTypeVariables   #-}+{-# LANGUAGE StandaloneDeriving    #-} +#if __GLASGOW_HASKELL__ >= 806+{-# LANGUAGE QuantifiedConstraints #-}+#endif+ {-| Module:      Spec.Utils Copyright:   (C) 2014-2017 Ryan Scott@@ -21,6 +28,9 @@ #endif     , genericTextShowSpec     , genericTextShow1Spec++    , Some(..)+    , GArbitrary(..)     ) where  import Data.Functor.Classes (Show1, showsPrec1)@@ -30,7 +40,7 @@  import Test.Hspec (Expectation, Spec, shouldBe) import Test.Hspec.QuickCheck (prop)-import Test.QuickCheck (Arbitrary)+import Test.QuickCheck (Arbitrary(..), Gen)  import TextShow (TextShow(..), TextShow1(..), showbPrec1, fromString) import TextShow.Generic@@ -40,6 +50,11 @@ import TextShow (TextShow2(..), showbPrec2) #endif +#if __GLASGOW_HASKELL__ >= 806+import GHC.Show (appPrec, appPrec1)+import TextShow (showbParen, showbSpace)+#endif+ -- | Expect a type's 'Show' instances to coincide for both 'String's and 'Text', -- irrespective of precedence. matchesTextShowSpec :: forall a. (Arbitrary a, Show a, TextShow a)@@ -107,3 +122,22 @@                       => Int -> f a -> Expectation prop_genericTextShow1 p x =     showbPrec1 p x `shouldBe` genericLiftShowbPrec showbPrec showbList p x++-- | A data type that existentially closes over something.+data Some t where+  Some :: t a -> Some t++#if __GLASGOW_HASKELL__ >= 806+deriving instance (forall a. Show (t a)) => Show (Some t)+instance (forall a. TextShow (t a)) => TextShow (Some t) where+  showbPrec p (Some x) =+    showbParen (p > appPrec) $+    fromString "Some" <> showbSpace <> showbPrec appPrec1 x+#endif++instance GArbitrary t => Arbitrary (Some t) where+  arbitrary = garbitrary++-- | An 'Arbitrary'-like class for 1-type-parameter GADTs.+class GArbitrary t where+  garbitrary :: Gen (Some t)
text-show.cabal view
@@ -1,5 +1,5 @@ name:                text-show-version:             3.10.1+version:             3.10.2 synopsis:            Efficient conversion of values into Text description:         @text-show@ offers a replacement for the @Show@ typeclass intended                      for use with @Text@ instead of @String@s. This package was created@@ -52,7 +52,9 @@                    , GHC == 8.8.4                    , GHC == 8.10.7                    , GHC == 9.0.2-                   , GHC == 9.2.2+                   , GHC == 9.2.7+                   , GHC == 9.4.4+                   , GHC == 9.6.1 extra-source-files:  CHANGELOG.md, README.md, include/*.h cabal-version:       >=1.10 @@ -175,14 +177,14 @@                      , th-lift               >= 0.7.6  && < 1    if flag(base-4-9)-    build-depends:     base                  >= 4.9 && < 4.18+    build-depends:     base                  >= 4.9 && < 4.19     cpp-options:       "-DNEW_FUNCTOR_CLASSES"   else     build-depends:     base                  >= 4.7 && < 4.9    if flag(template-haskell-2-11)-    build-depends:     template-haskell      >= 2.11 && < 2.20-                     , ghc-boot-th           >= 8.0  && < 9.5+    build-depends:     template-haskell      >= 2.11 && < 2.21+                     , ghc-boot-th           >= 8.0  && < 9.7   else     build-depends:     template-haskell      >= 2.9  && < 2.11 @@ -364,14 +366,14 @@                      , hspec                 >= 2      && < 3                      , QuickCheck            >= 2.12   && < 2.15                      , quickcheck-instances  >= 0.3.28 && < 0.4-                     , template-haskell      >= 2.9    && < 2.20+                     , template-haskell      >= 2.9    && < 2.21                      , text                  >= 0.11.1 && < 2.1                      , text-show                      , transformers-compat   >= 0.5    && < 1   build-tool-depends:  hspec-discover:hspec-discover    if flag(base-4-9)-    build-depends:     base                  >= 4.9 && < 4.18+    build-depends:     base                  >= 4.9 && < 4.19     cpp-options:       "-DNEW_FUNCTOR_CLASSES"   else     build-depends:     base                  >= 4.7 && < 4.9@@ -396,7 +398,7 @@ benchmark bench   type:                exitcode-stdio-1.0   main-is:             Bench.hs-  build-depends:       base      >= 4.5    && < 4.18+  build-depends:       base      >= 4.5    && < 4.19                      , criterion >= 1.1.4  && < 2                      , deepseq   >= 1.3    && < 2                      , ghc-prim