deriving-compat 0.6.4 → 0.6.5
raw patch · 4 files changed
+96/−5 lines, 4 filesdep ~containersdep ~th-abstractionPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: containers, th-abstraction
API changes (from Hackage documentation)
Files
- CHANGELOG.md +7/−0
- deriving-compat.cabal +1/−1
- src/Data/Deriving/Internal.hs +36/−0
- src/Text/Show/Deriving/Internal.hs +52/−4
CHANGELOG.md view
@@ -1,3 +1,10 @@+### 0.6.5 [2023.08.06]+* When generating `Show(1)(2)` instances with `Text.Show.Deriving` using GHC 9.8+ or later, data types that have fields of type `Int{8,16,32,64}#` or+ `Word{8,16,32,64}#` will be printed using extended literal syntax, mirroring+ corresponding changes introduced in GHC 9.8 (see+ https://github.com/ghc-proposals/ghc-proposals/pull/596).+ ### 0.6.4 [2023.08.06] * Support building with `template-haskell-2.21.*` (GHC 9.8). * The Template Haskell machinery now uses `TemplateHaskellQuotes` when building
deriving-compat.cabal view
@@ -1,5 +1,5 @@ name: deriving-compat-version: 0.6.4+version: 0.6.5 synopsis: Backports of GHC deriving extensions description: @deriving-compat@ provides Template Haskell functions that mimic @deriving@ extensions that were introduced or modified
src/Data/Deriving/Internal.hs view
@@ -56,6 +56,10 @@ import GHC.Exts import GHC.Read (choose, list, paren) import GHC.Show (showSpace)+#if MIN_VERSION_base(4,19,0)+import GHC.Int (Int8(..), Int16(..), Int32(..), Int64(..))+import GHC.Word (Word8(..), Word16(..), Word32(..), Word64(..))+#endif import Text.ParserCombinators.ReadPrec ( ReadPrec, (+++), pfail, prec, readPrec_to_S, readS_to_Prec@@ -2163,4 +2167,36 @@ wordToWord32HashValName :: Name wordToWord32HashValName = 'wordToWord32#+#endif++#if MIN_VERSION_base(4,19,0)+i8HashDataName :: Name+i8HashDataName = 'I8#++i16HashDataName :: Name+i16HashDataName = 'I16#++i32HashDataName :: Name+i32HashDataName = 'I32#++i64HashDataName :: Name+i64HashDataName = 'I64#++int64HashTypeName :: Name+int64HashTypeName = ''Int64#++w8HashDataName :: Name+w8HashDataName = 'W8#++w16HashDataName :: Name+w16HashDataName = 'W16#++w32HashDataName :: Name+w32HashDataName = 'W32#++w64HashDataName :: Name+w64HashDataName = 'W64#++word64HashTypeName :: Name+word64HashTypeName = ''Word64# #endif
src/Text/Show/Deriving/Internal.hs view
@@ -690,8 +690,50 @@ , primShowPostfixMod = twoHashE , primShowConv = id })-#if MIN_VERSION_base(4,13,0)+#if MIN_VERSION_base(4,19,0) , (int8HashTypeName, PrimShow+ { primShowBoxer = appE (conE i8HashDataName)+ , primShowPostfixMod = extendedLitE "Int8"+ , primShowConv = id+ })+ , (int16HashTypeName, PrimShow+ { primShowBoxer = appE (conE i16HashDataName)+ , primShowPostfixMod = extendedLitE "Int16"+ , primShowConv = id+ })+ , (int32HashTypeName, PrimShow+ { primShowBoxer = appE (conE i32HashDataName)+ , primShowPostfixMod = extendedLitE "Int32"+ , primShowConv = id+ })+ , (int64HashTypeName, PrimShow+ { primShowBoxer = appE (conE i64HashDataName)+ , primShowPostfixMod = extendedLitE "Int64"+ , primShowConv = id+ })+ , (word8HashTypeName, PrimShow+ { primShowBoxer = appE (conE w8HashDataName)+ , primShowPostfixMod = extendedLitE "Word8"+ , primShowConv = id+ })+ , (word16HashTypeName, PrimShow+ { primShowBoxer = appE (conE w16HashDataName)+ , primShowPostfixMod = extendedLitE "Word16"+ , primShowConv = id+ })+ , (word32HashTypeName, PrimShow+ { primShowBoxer = appE (conE w32HashDataName)+ , primShowPostfixMod = extendedLitE "Word32"+ , primShowConv = id+ })+ , (word64HashTypeName, PrimShow+ { primShowBoxer = appE (conE w64HashDataName)+ , primShowPostfixMod = extendedLitE "Word64"+ , primShowConv = id+ })+#else+# if MIN_VERSION_base(4,13,0)+ , (int8HashTypeName, PrimShow { primShowBoxer = appE (conE iHashDataName) . appE (varE int8ToIntHashValName) , primShowPostfixMod = oneHashE , primShowConv = mkNarrowE intToInt8HashValName@@ -711,8 +753,8 @@ , primShowPostfixMod = twoHashE , primShowConv = mkNarrowE wordToWord16HashValName })-#endif-#if MIN_VERSION_base(4,16,0)+# endif+# if MIN_VERSION_base(4,16,0) , (int32HashTypeName, PrimShow { primShowBoxer = appE (conE iHashDataName) . appE (varE int32ToIntHashValName) , primShowPostfixMod = oneHashE@@ -723,10 +765,11 @@ , primShowPostfixMod = twoHashE , primShowConv = mkNarrowE wordToWord32HashValName })+# endif #endif ] -#if MIN_VERSION_base(4,13,0)+#if MIN_VERSION_base(4,13,0) && !(MIN_VERSION_base(4,19,0)) mkNarrowE :: Name -> Q Exp -> Q Exp mkNarrowE narrowName e = foldr (`infixApp` varE composeValName)@@ -739,3 +782,8 @@ oneHashE, twoHashE :: Q Exp oneHashE = varE showCharValName `appE` charE '#' twoHashE = varE showStringValName `appE` stringE "##"++#if MIN_VERSION_base(4,19,0)+extendedLitE :: String -> Q Exp+extendedLitE suffix = varE showStringValName `appE` stringE ("#" ++ suffix)+#endif