text-show 3.8 → 3.8.1
raw patch · 5 files changed
+33/−23 lines, 5 filesdep ~th-abstraction
Dependency ranges changed: th-abstraction
Files
- CHANGELOG.md +3/−0
- src/TextShow/TH/Internal.hs +26/−18
- tests/Instances/Data/Typeable.hs +0/−1
- tests/Instances/GHC/TypeLits.hs +1/−1
- text-show.cabal +3/−3
CHANGELOG.md view
@@ -1,3 +1,6 @@+### 3.8.1 [2019.04.26]+* Support `th-abstraction-0.3` or later.+ ## 3.8 [2019.03.19] * Remove the `TextShow I16` instance from `TextShow.Data.Text`. The usefulness of this instance was dubious at best, and moreover, it was actively causing
src/TextShow/TH/Internal.hs view
@@ -458,23 +458,27 @@ deriveTextShowClass tsClass opts name = do info <- reifyDatatype name case info of- DatatypeInfo { datatypeContext = ctxt- , datatypeName = parentName- , datatypeVars = vars- , datatypeVariant = variant- , datatypeCons = cons+ DatatypeInfo { datatypeContext = ctxt+ , datatypeName = parentName+#if MIN_VERSION_th_abstraction(0,3,0)+ , datatypeInstTypes = instTys+#else+ , datatypeVars = instTys+#endif+ , datatypeVariant = variant+ , datatypeCons = cons } -> do (instanceCxt, instanceType)- <- buildTypeInstance tsClass parentName ctxt vars variant+ <- buildTypeInstance tsClass parentName ctxt instTys variant (:[]) <$> instanceD (return instanceCxt) (return instanceType)- (showbPrecDecs tsClass opts vars cons)+ (showbPrecDecs tsClass opts instTys cons) -- | Generates a declaration defining the primary function corresponding to a -- particular class (showbPrec for TextShow, liftShowbPrec for TextShow1, and -- liftShowbPrec2 for TextShow2). showbPrecDecs :: TextShowClass -> Options -> [Type] -> [ConstructorInfo] -> [Q Dec]-showbPrecDecs tsClass opts vars cons =+showbPrecDecs tsClass opts instTys cons = [genMethod ShowbPrec (showbPrecName tsClass)] ++ if tsClass == TextShow && shouldGenTextMethods then [genMethod ShowtPrec 'showtPrec, genMethod ShowtlPrec 'showtlPrec]@@ -490,7 +494,7 @@ genMethod method methodName = funD methodName [ clause []- (normalB $ makeTextShowForCons tsClass method opts vars cons)+ (normalB $ makeTextShowForCons tsClass method opts instTys cons) [] ] @@ -501,30 +505,34 @@ makeShowbPrecClass tsClass tsFun opts name = do info <- reifyDatatype name case info of- DatatypeInfo { datatypeContext = ctxt- , datatypeName = parentName- , datatypeVars = vars- , datatypeVariant = variant- , datatypeCons = cons+ DatatypeInfo { datatypeContext = ctxt+ , datatypeName = parentName+#if MIN_VERSION_th_abstraction(0,3,0)+ , datatypeInstTypes = instTys+#else+ , datatypeVars = instTys+#endif+ , datatypeVariant = variant+ , datatypeCons = cons } -> -- We force buildTypeInstance here since it performs some checks for whether -- or not the provided datatype can actually have showbPrec/liftShowbPrec/etc. -- implemented for it, and produces errors if it can't.- buildTypeInstance tsClass parentName ctxt vars variant- >> makeTextShowForCons tsClass tsFun opts vars cons+ buildTypeInstance tsClass parentName ctxt instTys variant+ >> makeTextShowForCons tsClass tsFun opts instTys cons -- | Generates a lambda expression for showbPrec/liftShowbPrec/etc. for the -- given constructors. All constructors must be from the same type. makeTextShowForCons :: TextShowClass -> TextShowFun -> Options -> [Type] -> [ConstructorInfo] -> Q Exp-makeTextShowForCons tsClass tsFun opts vars cons = do+makeTextShowForCons tsClass tsFun opts instTys cons = do p <- newName "p" value <- newName "value" sps <- newNameList "sp" $ fromEnum tsClass sls <- newNameList "sl" $ fromEnum tsClass let spls = zip sps sls spsAndSls = interleave sps sls- lastTyVars = map varTToName $ drop (length vars - fromEnum tsClass) vars+ lastTyVars = map varTToName $ drop (length instTys - fromEnum tsClass) instTys splMap = Map.fromList $ zip lastTyVars spls makeFun
tests/Instances/Data/Typeable.hs view
@@ -30,7 +30,6 @@ # else import GHC.Word (Word(..)) # endif-import Test.QuickCheck (oneof) #else import Data.Typeable.Internal (TyCon(..)) #endif
tests/Instances/GHC/TypeLits.hs view
@@ -37,7 +37,7 @@ nat <- getNonNegative <$> arbitrary case someNatVal nat of Just sn -> pure sn- Nothing -> fail "Negative natural number" -- Should never happen+ Nothing -> error "Negative natural number" -- Should never happen instance Arbitrary SomeSymbol where arbitrary = someSymbolVal <$> arbitrary
text-show.cabal view
@@ -1,5 +1,5 @@ name: text-show-version: 3.8+version: 3.8.1 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@@ -166,7 +166,7 @@ , semigroups >= 0.17 && < 1 , tagged >= 0.4.4 && < 1 , text >= 0.11.1 && < 1.3- , th-abstraction >= 0.2.2 && < 0.3+ , th-abstraction >= 0.2.2 && < 0.4 , th-lift >= 0.7.6 && < 1 , void >= 0.5 && < 1 @@ -347,7 +347,7 @@ , ghc-prim , hspec >= 2 && < 3 , nats >= 0.1 && < 2- , QuickCheck >= 2.12 && < 2.13+ , QuickCheck >= 2.12 && < 2.14 , quickcheck-instances >= 0.3.18 && < 0.4 , semigroups >= 0.18.3 && < 1 , tagged >= 0.8.3 && < 1