diff --git a/Data/Generics/SYB/WithClass/Derive.hs b/Data/Generics/SYB/WithClass/Derive.hs
--- a/Data/Generics/SYB/WithClass/Derive.hs
+++ b/Data/Generics/SYB/WithClass/Derive.hs
@@ -268,9 +268,13 @@
                                    fields = map getField xs
                                    types  = map getType xs
                                in (c, length xs, Just fields, types)
+#if MIN_VERSION_template_haskell(2,17,0)
+       varName (PlainTV n _) = n
+       varName (KindedTV n _ _) = n
+#else
        varName (PlainTV n) = n
        varName (KindedTV n _) = n
-
+#endif
 --
 -- | Derives the Data and Typeable instances for a single given data type.
 --
diff --git a/Data/Generics/SYB/WithClass/Instances.hs b/Data/Generics/SYB/WithClass/Instances.hs
--- a/Data/Generics/SYB/WithClass/Instances.hs
+++ b/Data/Generics/SYB/WithClass/Instances.hs
@@ -5,7 +5,7 @@
 --
 ------------------------------------------------------------------------------
 
-{-# LANGUAGE TemplateHaskell, FlexibleInstances,
+{-# LANGUAGE TemplateHaskell, FlexibleContexts, FlexibleInstances,
              UndecidableInstances, CPP, MultiParamTypeClasses #-}
 #if MIN_VERSION_base(4,7,0)
 {-# LANGUAGE StandaloneDeriving, DeriveDataTypeable #-}
diff --git a/syb-with-class.cabal b/syb-with-class.cabal
--- a/syb-with-class.cabal
+++ b/syb-with-class.cabal
@@ -1,5 +1,5 @@
 Name:               syb-with-class
-Version:            0.6.1.13
+Version:            0.6.1.14
 License:            BSD3
 License-file:       LICENSE
 Copyright:          2004 - 2008 The University of Glasgow, CWI,
@@ -15,7 +15,7 @@
     Classes, and Template Haskell code to generate instances, for the
     Scrap Your Boilerplate With Class system.
 Category:           Data
-Tested-With:        GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.2, GHC==8.0.1, GHC==8.2.1, GHC==8.4.3, GHC==8.6.3, GHC==8.8.3, GHC==8.10.1
+Tested-With:        GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC==8.0.2, GHC==8.2.2, GHC==8.4.4, GHC==8.6.5, GHC==8.8.4, GHC==8.10.7, GHC==9.0.2, GHC==9.2.2
 Build-Type:         Simple
 Cabal-Version:      >= 1.10
 
@@ -25,7 +25,7 @@
 
 Library
     Default-Language: Haskell2010
-    Build-Depends:      base >= 3 && < 5, template-haskell >= 2.4 && < 2.17, bytestring, array, containers
+    Build-Depends:      base >= 3 && < 5, template-haskell >= 2.4 && < 2.19, bytestring, array, containers
     Exposed-modules:
         Data.Generics.SYB.WithClass.Basics
         Data.Generics.SYB.WithClass.Context
