acid-state / safecopy

An extension to Data.Serialize with built-in version control
60 stars 37 forks source link

Need changes for GHC-9.0 #82

Closed phadej closed 3 years ago

phadej commented 3 years ago
src/Data/SafeCopy/Derive.hs:222:14: error:
    • Expecting one more argument to ‘TyVarBndr’
      Expected a type, but ‘TyVarBndr’ has kind ‘* -> *’
    • In the type signature: tyVarName :: TyVarBndr -> Name
    |
222 | tyVarName :: TyVarBndr -> Name
    |              ^^^^^^^^^

I used following patch

diff --git a/src/Data/SafeCopy/Derive.hs b/src/Data/SafeCopy/Derive.hs
index 34e29fc..30494c3 100644
--- a/src/Data/SafeCopy/Derive.hs
+++ b/src/Data/SafeCopy/Derive.hs
@@ -219,9 +219,15 @@ forceTag :: DeriveType -> Bool
 forceTag HappstackData = True
 forceTag _             = False

+#if MIN_VERSION_template_haskell(2,17,0)
+tyVarName :: TyVarBndr s -> Name
+tyVarName (PlainTV n _) = n
+tyVarName (KindedTV n _ _) = n
+#else
 tyVarName :: TyVarBndr -> Name
 tyVarName (PlainTV n) = n
 tyVarName (KindedTV n _) = n
+#endif

 internalDeriveSafeCopy :: DeriveType -> Version a -> Name -> Name -> Q [Dec]
 internalDeriveSafeCopy deriveType versionId kindName tyName = do
diff --git a/test/generic.hs b/test/generic.hs
index b3eb6fb..d777328 100644
--- a/test/generic.hs
+++ b/test/generic.hs
@@ -217,9 +217,9 @@ t2 = (T2 'b')
 t3 = (T3 'c')
 t4 = T4 100 200 300

-$(deriveSafeCopy 3 'base ''T1)
 $(deriveSafeCopy 4 'base ''T2)
 $(deriveSafeCopy 5 'base ''T3)
+$(deriveSafeCopy 3 'base ''T1)
 $(deriveSafeCopy 6 'base ''T4)

 data T1G = T1G Char T2G T3G deriving (Generic, Show)
phadej commented 3 years ago

Also test-suite needs reordering due TH splices + instances

stepcut commented 3 years ago

https://hackage.haskell.org/package/safecopy-0.10.3.1

phadej commented 3 years ago

Thanks!