diff --git a/Retrie/CPP.hs b/Retrie/CPP.hs
--- a/Retrie/CPP.hs
+++ b/Retrie/CPP.hs
@@ -325,8 +325,13 @@
 insertImports
   :: Monad m
   => [AnnotatedImports]   -- ^ imports and their annotations
+#if __GLASGOW_HASKELL__ < 906
   -> Located HsModule     -- ^ target module
   -> TransformT m (Located HsModule)
+#else
+  -> Located (HsModule GhcPs)     -- ^ target module
+  -> TransformT m (Located (HsModule GhcPs))
+#endif
 insertImports is (L l m) = do
   imps <- graftA $ filterAndFlatten (unLoc <$> hsmodName m) is
   let
@@ -346,7 +351,11 @@
   ((==) `on` unLoc . ideclName) x y
   && ((==) `on` ideclQualified) x y
   && ((==) `on` ideclAs) x y
+#if __GLASGOW_HASKELL__ <= 904
   && ((==) `on` ideclHiding) x y
+#else
+  && ((==) `on` ideclImportList) x y
+#endif
 #if __GLASGOW_HASKELL__ < 904
   && ((==) `on` ideclPkgQual) x y
 #else
diff --git a/Retrie/Context.hs b/Retrie/Context.hs
--- a/Retrie/Context.hs
+++ b/Retrie/Context.hs
@@ -11,11 +11,6 @@
   ( ContextUpdater
   , updateContext
   , emptyContext
-  -- internal details useful for custom ContextUpdater
-  , addInScope
-  , addBinders
-  , updateSubstitution
-  , updateBinder
   ) where
 
 import Control.Monad.IO.Class
diff --git a/Retrie/Elaborate.hs b/Retrie/Elaborate.hs
--- a/Retrie/Elaborate.hs
+++ b/Retrie/Elaborate.hs
@@ -103,7 +103,7 @@
 allMatches ctxt matchResults = do
   results <-
     forM matchResults $ \(sub, RewriterResult{..}) -> do
-      result <- lift $ liftIO $ rrTransformer ctxt $ MatchResult sub rrTemplate
+      result <- TransformT $ lift $ liftIO $ rrTransformer ctxt $ MatchResult sub rrTemplate
       return (rrQuantifiers, result)
   return
     [ project <$> result
diff --git a/Retrie/ExactPrint.hs b/Retrie/ExactPrint.hs
--- a/Retrie/ExactPrint.hs
+++ b/Retrie/ExactPrint.hs
@@ -49,6 +49,7 @@
   ) where
 
 import Control.Exception
+import Control.Monad
 import Control.Monad.State.Lazy hiding (fix)
 -- import Data.Function (on)
 import Data.List (transpose)
diff --git a/Retrie/ExactPrint/Annotated.hs b/Retrie/ExactPrint/Annotated.hs
--- a/Retrie/ExactPrint/Annotated.hs
+++ b/Retrie/ExactPrint/Annotated.hs
@@ -8,6 +8,7 @@
 {-# LANGUAGE ScopedTypeVariables #-}
 {-# LANGUAGE StandaloneDeriving #-}
 {-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE CPP #-}
 module Retrie.ExactPrint.Annotated
   ( -- * Annotated
     Annotated
@@ -37,6 +38,7 @@
 
 import Control.Monad.State.Lazy hiding (fix)
 import Data.Default as D
+
 import Data.Functor.Identity
 
 import Language.Haskell.GHC.ExactPrint hiding
@@ -59,7 +61,11 @@
 type AnnotatedHsType = Annotated (LHsType GhcPs)
 type AnnotatedImport = Annotated (LImportDecl GhcPs)
 type AnnotatedImports = Annotated [LImportDecl GhcPs]
+#if __GLASGOW_HASKELL__ >= 906
+type AnnotatedModule = Annotated (Located (HsModule GhcPs))
+#else
 type AnnotatedModule = Annotated (Located HsModule)
+#endif
 type AnnotatedPat = Annotated (LPat GhcPs)
 type AnnotatedStmt = Annotated (LStmt GhcPs (LHsExpr GhcPs))
 
diff --git a/Retrie/Expr.hs b/Retrie/Expr.hs
--- a/Retrie/Expr.hs
+++ b/Retrie/Expr.hs
@@ -35,6 +35,7 @@
   , wildSupply
   ) where
 
+import Control.Monad
 import Control.Monad.State.Lazy
 import Data.Functor.Identity
 -- import qualified Data.Map as M
diff --git a/Retrie/GHC.hs b/Retrie/GHC.hs
--- a/Retrie/GHC.hs
+++ b/Retrie/GHC.hs
@@ -53,7 +53,11 @@
 import GHC.Types.Unique
 import GHC.Types.Unique.FM
 import GHC.Types.Unique.Set
+#if __GLASGOW_HASKELL__ >= 906
+import Language.Haskell.Syntax.Basic as GHC.Unit.Module.Name
+#else
 import GHC.Unit.Module.Name
+#endif
 import GHC.Utils.Outputable (Outputable (ppr))
 
 import Data.Bifunctor (second)
@@ -92,7 +96,11 @@
 tyvarRdrName _ = Nothing
 
 -- fixityDecls :: HsModule -> [(LIdP p, Fixity)]
+#if __GLASGOW_HASKELL__ >= 906
+fixityDecls :: HsModule GhcPs -> [(LocatedN RdrName, Fixity)]
+#else
 fixityDecls :: HsModule -> [(LocatedN RdrName, Fixity)]
+#endif
 fixityDecls m =
   [ (nm, fixity)
   | L _ (SigD _ (FixSig _ (FixitySig _ nms fixity))) <- hsmodDecls m
@@ -100,7 +108,11 @@
   ]
 
 ruleInfo :: RuleDecl GhcPs -> [RuleInfo]
+#if __GLASGOW_HASKELL__ >= 906
+ruleInfo (HsRule _ (L _ riName) _ tyBs valBs riLHS riRHS) =
+#else
 ruleInfo (HsRule _ (L _ (_, riName)) _ tyBs valBs riLHS riRHS) =
+#endif
   let
     riQuantifiers =
       map unLoc (tyBindersToLocatedRdrNames (fromMaybe [] tyBs)) ++
diff --git a/Retrie/Monad.hs b/Retrie/Monad.hs
--- a/Retrie/Monad.hs
+++ b/Retrie/Monad.hs
@@ -28,6 +28,7 @@
   , runRetrie
   ) where
 
+import Control.Monad
 import Control.Monad.IO.Class
 import Control.Monad.State.Strict
 import Control.Monad.RWS
diff --git a/Retrie/PatternMap/Instances.hs b/Retrie/PatternMap/Instances.hs
--- a/Retrie/PatternMap/Instances.hs
+++ b/Retrie/PatternMap/Instances.hs
@@ -422,8 +422,10 @@
 #else
       go HsTypedBracket{} = missingSyntax "HsTypedBracket"
       go HsUntypedBracket{} = missingSyntax "HsUntypedBracket"
+#if __GLASGOW_HASKELL__ < 906
       go HsSpliceE{} = missingSyntax "HsSpliceE"
 #endif
+#endif
 #if __GLASGOW_HASKELL__ < 810
       go HsArrApp{} = missingSyntax "HsArrApp"
       go HsArrForm{} = missingSyntax "HsArrForm"
@@ -676,11 +678,12 @@
 instance PatternMap CDMap where
 #if __GLASGOW_HASKELL__ < 810
   type Key CDMap = HsConDetails (LPat GhcPs) (HsRecFields GhcPs (LPat GhcPs))
-#else
+#elif __GLASGOW_HASKELL__ < 906
   -- We must manually expand 'LPat' to avoid UndecidableInstances in GHC 8.10+
   type Key CDMap = HsConDetails (HsPatSigType GhcPs) (LocatedA (Pat GhcPs)) (HsRecFields GhcPs (LocatedA (Pat GhcPs)))
   -- type HsConPatDetails p = HsConDetails (HsPatSigType (NoGhcTc p)) (LPat p) (HsRecFields p (LPat p))
-
+#else
+  type Key CDMap = HsConDetails (HsConPatTyArg GhcPs) (LocatedA (Pat GhcPs)) (HsRecFields GhcPs (LocatedA (Pat GhcPs)))
 #endif
 
   mEmpty :: CDMap a
@@ -1035,10 +1038,10 @@
       go (FunBind _ _ mg _ _) = m { bmFunBind = mAlter env vs mg f (bmFunBind m) }
       go (VarBind _ _ e _) = m { bmVarBind = mAlter env vs e f (bmVarBind m) }
 #else
-      go (FunBind _ _ mg _) = m { bmFunBind = mAlter env vs mg f (bmFunBind m) }
+      go (FunBind{fun_matches = mg}) = m { bmFunBind = mAlter env vs mg f (bmFunBind m) }
       go (VarBind _ _ e) = m { bmVarBind = mAlter env vs e f (bmVarBind m) }
 #endif
-      go (PatBind _ lhs rhs _) =
+      go (PatBind{pat_lhs=lhs, pat_rhs=rhs}) =
         m { bmPatBind = mAlter env vs lhs
               (toA $ mAlter env vs rhs f) (bmPatBind m) }
 #if __GLASGOW_HASKELL__ < 904
@@ -1054,10 +1057,10 @@
       go (FunBind _ _ mg _ _) = mapFor bmFunBind >=> mMatch env mg
       go (VarBind _ _ e _) = mapFor bmVarBind >=> mMatch env e
 #else
-      go (FunBind _ _ mg _) = mapFor bmFunBind >=> mMatch env mg
+      go (FunBind{fun_matches = mg}) = mapFor bmFunBind >=> mMatch env mg
       go (VarBind _ _ e) = mapFor bmVarBind >=> mMatch env e
 #endif
-      go (PatBind _ lhs rhs _)
+      go (PatBind{pat_lhs=lhs, pat_rhs=rhs})
         = mapFor bmPatBind >=> mMatch env lhs >=> mMatch env rhs
       go _ = const [] -- TODO
 
diff --git a/Retrie/Rewrites/Function.hs b/Retrie/Rewrites/Function.hs
--- a/Retrie/Rewrites/Function.hs
+++ b/Retrie/Rewrites/Function.hs
@@ -53,7 +53,7 @@
 getImports
   :: LibDir -> Direction -> Maybe (LocatedA ModuleName) -> TransformT IO AnnotatedImports
 getImports libdir RightToLeft (Just (L _ mn)) = -- See Note [fold only]
-  lift $ liftIO $ parseImports libdir ["import " ++ moduleNameString mn]
+  TransformT $ lift $ liftIO $ parseImports libdir ["import " ++ moduleNameString mn]
 getImports _ _ _ = return mempty
 
 matchToRewrites
@@ -81,7 +81,11 @@
     go WildPat{} = True
     go VarPat{} = True
     go (LazyPat _ p) = irrefutablePat p
+#if __GLASGOW_HASKELL__ <= 904
     go (AsPat _ _ p) = irrefutablePat p
+#else
+    go (AsPat _ _ _ p) = irrefutablePat p
+#endif
 #if __GLASGOW_HASKELL__ < 904
     go (ParPat _ p) = irrefutablePat p
 #else
diff --git a/Retrie/Rewrites/Patterns.hs b/Retrie/Rewrites/Patterns.hs
--- a/Retrie/Rewrites/Patterns.hs
+++ b/Retrie/Rewrites/Patterns.hs
@@ -86,7 +86,11 @@
   mkConPatIn patName params'
   where
 
+#if __GLASGOW_HASKELL__ <= 904
     convertTyVars :: (Monad m) => [Void] -> TransformT m [HsPatSigType GhcPs]
+#else
+    convertTyVars :: (Monad m) => [Void] -> TransformT m [HsConPatTyArg GhcPs]
+#endif
     convertTyVars _ = return []
 
     convertFields :: (Monad m) => [RecordPatSynField GhcPs]
diff --git a/Retrie/Run.hs b/Retrie/Run.hs
--- a/Retrie/Run.hs
+++ b/Retrie/Run.hs
@@ -18,6 +18,7 @@
   , writeExtract
   ) where
 
+import Control.Monad
 import Control.Monad.State.Strict
 import Data.Char
 import Data.List
diff --git a/Retrie/Types.hs b/Retrie/Types.hs
--- a/Retrie/Types.hs
+++ b/Retrie/Types.hs
@@ -47,6 +47,7 @@
   , Context(..)
   ) where
 
+import Control.Monad
 import Control.Monad.IO.Class
 import Control.Monad.State
 import Data.Bifunctor
@@ -328,7 +329,7 @@
 firstMatch ctxt ((sub, RewriterResult{..}):matchResults) = do
   -- 'firstMatch' is lazy in 'rrTransformer', only running it enough
   -- times to get the first valid MatchResult.
-  matchResult <- lift $ liftIO $ rrTransformer ctxt (MatchResult sub rrTemplate)
+  matchResult <- TransformT $ lift $ liftIO $ rrTransformer ctxt (MatchResult sub rrTemplate)
   case matchResult of
     MatchResult sub' _
       -- Check that all quantifiers from the original rewrite have mappings
diff --git a/retrie.cabal b/retrie.cabal
--- a/retrie.cabal
+++ b/retrie.cabal
@@ -4,7 +4,7 @@
 -- LICENSE file in the root directory of this source tree.
 --
 name: retrie
-version: 1.2.1.1
+version: 1.2.2
 synopsis: A powerful, easy-to-use codemodding tool for Haskell.
 homepage: https://github.com/facebookincubator/retrie
 bug-reports: https://github.com/facebookincubator/retrie/issues
@@ -23,7 +23,7 @@
   README.md
   tests/inputs/*.custom
   tests/inputs/*.test
-tested-with: GHC ==9.2.1, GHC ==9.4.1
+tested-with: GHC ==9.2.1, GHC ==9.4.1, GHC ==9.6.1
 
 description:
   Retrie is a tool for codemodding Haskell. Key goals include:
@@ -77,17 +77,17 @@
   build-depends:
     ansi-terminal >= 0.10.3 && < 0.12,
     async >= 2.2.2 && < 2.3,
-    base >= 4.11 && < 4.18,
+    base >= 4.11 && < 4.19,
     bytestring >= 0.10.8 && < 0.12,
     containers >= 0.5.11 && < 0.7,
     data-default >= 0.7.1 && < 0.8,
     directory >= 1.3.1 && < 1.4,
     filepath >= 1.4.2 && < 1.5,
-    ghc >= 9.2 && < 9.5,
-    ghc-exactprint >= 1.5.0 && < 1.7,
+    ghc >= 9.2 && < 9.7,
+    ghc-exactprint >= 1.5.0 && < 1.8,
     list-t >= 1.0.4 && < 1.1,
     mtl >= 2.2.2 && < 2.3,
-    optparse-applicative >= 0.15.1 && < 0.17,
+    optparse-applicative >= 0.15.1 && < 0.18,
     process >= 1.6.3 && < 1.7,
     random-shuffle >= 0.0.4 && < 0.1,
     syb >= 0.7.1 && < 0.8,
