diff --git a/CHANGES.markdown b/CHANGES.markdown
--- a/CHANGES.markdown
+++ b/CHANGES.markdown
@@ -1,3 +1,6 @@
+Changes in 0.22.3
+  - Use `-Wno-unused-packages` when extracting comments
+
 Changes in 0.22.2
   - GHC 9.8 compatibility
 
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2009-2023 Simon Hengel <sol@typeful.net>
+Copyright (c) 2009-2024 Simon Hengel <sol@typeful.net>
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -132,6 +132,9 @@
 - If you use properties you need to pass `--build-depends=QuickCheck` and
   `--build-depends=template-haskell` to `cabal repl`.
 
+- You likely want to reset the warning strategy for `cabal repl` with
+  `--repl-options='-w -Wdefault'`.
+
 - `doctest` always uses the version of GHC it was compiled with.  Reinstalling
   `doctest` with `cabal install doctest --overwrite-policy=always` before each
   invocation ensures that it uses the same version of GHC as is on the `PATH`.
@@ -144,7 +147,7 @@
 So a more robust way to call `doctest` is as follows:
 
 ```
-cabal install doctest --overwrite-policy=always && cabal build && cabal repl --build-depends=QuickCheck --build-depends=template-haskell --with-ghc=doctest
+cabal install doctest --overwrite-policy=always && cabal build && cabal repl --build-depends=QuickCheck --build-depends=template-haskell --with-ghc=doctest --repl-options='-w -Wdefault'
 ```
 
 (This is what you want to use on CI.)
@@ -430,7 +433,7 @@
 
 ```haskell
 -- |
--- >>> :set -XTupleSections
+-- >>> :seti -XTupleSections
 -- >>> fst' $ (1,) 2
 -- 1
 fst' :: (a, b) -> a
@@ -450,7 +453,7 @@
 
 ```haskell
 -- $
--- >>> :set -XTupleSections
+-- >>> :seti -XTupleSections
 ```
 
 [language-pragma]: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/exts/pragmas.html#language-pragma
diff --git a/doctest.cabal b/doctest.cabal
--- a/doctest.cabal
+++ b/doctest.cabal
@@ -5,7 +5,7 @@
 -- see: https://github.com/sol/hpack
 
 name:           doctest
-version:        0.22.2
+version:        0.22.3
 synopsis:       Test interactive Haskell examples
 description:    `doctest` is a tool that checks [examples](https://www.haskell.org/haddock/doc/html/ch03s08.html#idm140354810775744)
                 and [properties](https://www.haskell.org/haddock/doc/html/ch03s08.html#idm140354810771856)
@@ -18,7 +18,7 @@
 homepage:       https://github.com/sol/doctest#readme
 license:        MIT
 license-file:   LICENSE
-copyright:      (c) 2009-2023 Simon Hengel
+copyright:      (c) 2009-2024 Simon Hengel
 author:         Simon Hengel <sol@typeful.net>
 maintainer:     Simon Hengel <sol@typeful.net>
 build-type:     Simple
@@ -146,7 +146,7 @@
     , directory
     , exceptions
     , filepath
-    , ghc >=8.0 && <9.10
+    , ghc >=8.0 && <9.12
     , ghc-paths >=0.1.0.9
     , process
     , syb >=0.3
@@ -175,7 +175,7 @@
     , doctest
     , exceptions
     , filepath
-    , ghc >=8.0 && <9.10
+    , ghc >=8.0 && <9.12
     , ghc-paths >=0.1.0.9
     , process
     , syb >=0.3
@@ -246,7 +246,7 @@
     , directory
     , exceptions
     , filepath
-    , ghc >=8.0 && <9.10
+    , ghc >=8.0 && <9.12
     , ghc-paths >=0.1.0.9
     , hspec >=2.3.0
     , hspec-core >=2.3.0
diff --git a/src/Extract.hs b/src/Extract.hs
--- a/src/Extract.hs
+++ b/src/Extract.hs
@@ -1,11 +1,9 @@
 {-# LANGUAGE CPP #-}
 module Extract (Module(..), extract) where
 
-import           Prelude hiding (mod, concat)
-import           Control.Monad
+import           Imports hiding (mod, concat)
 import           Control.Exception
 import           Data.List (partition, isSuffixOf)
-import           Data.Maybe
 
 import           Control.DeepSeq (deepseq, NFData(rnf))
 import           Data.Generics
@@ -166,7 +164,7 @@
 # if __GLASGOW_HASKELL__ >= 902
       hsc_env' <- liftIO (initializePlugins hsc_env)
       setSession hsc_env'
-      return $ modsum
+      return modsum
 # else
       dynflags' <- liftIO (initializePlugins hsc_env (GHC.ms_hspp_opts modsum))
       return $ modsum { ms_hspp_opts = dynflags' }
@@ -182,7 +180,15 @@
 extract :: [String] -> IO [Module (Located String)]
 extract args = do
   packageDBArgs <- getPackageDBArgs
-  let args'  = args ++ packageDBArgs
+  let
+    args' = args ++
+#if __GLASGOW_HASKELL__ >= 810
+      -- `ghci` ignores unused packages in certain situation.  This ensures
+      -- that we don't fail in situations where `ghci` would not.
+      "-Wno-unused-packages" :
+#endif
+      packageDBArgs
+
   mods <- parse args'
   let docs = map (fmap (fmap convertDosLineEndings) . extractFromModule) mods
 
@@ -253,7 +259,7 @@
   in
     flip fmap docStrs $ \docStr -> (lookup (getLoc docStr) docStrNames, docStr)
   where
-    extractAll z = everything (++) ((mkQ [] ((:[]) . z)))
+    extractAll z = everything (++) (mkQ [] ((:[]) . z))
 
     extractDocDocString :: LHsDoc GhcPs -> LHsDocString
     extractDocDocString = fmap hsDocString
diff --git a/src/Imports.hs b/src/Imports.hs
--- a/src/Imports.hs
+++ b/src/Imports.hs
@@ -2,4 +2,5 @@
 
 import           Prelude as Imports
 import           Data.Monoid as Imports
+import           Data.Maybe as Imports
 import           Control.Monad as Imports
diff --git a/src/Language/Haskell/GhciWrapper.hs b/src/Language/Haskell/GhciWrapper.hs
--- a/src/Language/Haskell/GhciWrapper.hs
+++ b/src/Language/Haskell/GhciWrapper.hs
@@ -16,7 +16,6 @@
 import           System.Exit
 import           Control.Exception
 import           Data.List (isSuffixOf)
-import           Data.Maybe
 
 data Config = Config {
   configGhci :: String
diff --git a/src/Parse.hs b/src/Parse.hs
--- a/src/Parse.hs
+++ b/src/Parse.hs
@@ -21,7 +21,6 @@
 
 import           Data.Char (isSpace)
 import           Data.List (isPrefixOf, stripPrefix)
-import           Data.Maybe
 import           Data.String
 import           Extract
 import           Location
diff --git a/src/Property.hs b/src/Property.hs
--- a/src/Property.hs
+++ b/src/Property.hs
@@ -11,7 +11,6 @@
 import           Imports
 
 import           Data.List
-import           Data.Maybe
 import           Data.Foldable
 
 import           Util
diff --git a/src/Run.hs b/src/Run.hs
--- a/src/Run.hs
+++ b/src/Run.hs
@@ -115,10 +115,7 @@
 getAddDistArgs :: IO ([String] -> [String])
 getAddDistArgs = do
     env <- getEnvironment
-    let dist =
-            case lookup "HASKELL_DIST_DIR" env of
-                Nothing -> "dist"
-                Just x -> x
+    let dist = fromMaybe "dist" $ lookup "HASKELL_DIST_DIR" env
         autogen = dist ++ "/build/autogen/"
         cabalMacros = autogen ++ "cabal_macros.h"
 
@@ -143,7 +140,7 @@
 isSuccess s = sErrors s == 0 && sFailures s == 0
 
 evaluateResult :: Result -> IO ()
-evaluateResult r = when (not $ isSuccess r) exitFailure
+evaluateResult r = unless (isSuccess r) exitFailure
 
 doctestWithResult :: Config -> IO Result
 doctestWithResult config = do
diff --git a/test/Language/Haskell/GhciWrapperSpec.hs b/test/Language/Haskell/GhciWrapperSpec.hs
--- a/test/Language/Haskell/GhciWrapperSpec.hs
+++ b/test/Language/Haskell/GhciWrapperSpec.hs
@@ -102,7 +102,7 @@
 
     context "with -XOverloadedStrings, -Wall and -Werror" $ do
       it "does not fail on marker expression (bug fix)" $ withInterpreter $ \ghci -> do
-        ghci ":set -XOverloadedStrings -Wall -Werror" `shouldReturn` ""
+        ghci ":seti -XOverloadedStrings -Wall -Werror" `shouldReturn` ""
         ghci "putStrLn \"foo\"" `shouldReturn` "foo\n"
 
     context "with NoImplicitPrelude" $ do
diff --git a/test/RunSpec.hs b/test/RunSpec.hs
--- a/test/RunSpec.hs
+++ b/test/RunSpec.hs
@@ -126,15 +126,20 @@
 
       it "prints a useful error message" $ do
         (r, _) <- hCapture [stderr] (E.try action :: IO (Either ExitCode Summary))
-        stripAnsiColors (removeLoadedPackageEnvironment r) `shouldBe` unlines [
-            ""
+        stripAnsiColors (removeLoadedPackageEnvironment r) `shouldBe` unlines (
+#if __GLASGOW_HASKELL__ < 910
+          "" :
+#endif
 #if __GLASGOW_HASKELL__ >= 906
-          , "Foo.hs:6:1: error: [GHC-58481]"
+          [ "Foo.hs:6:1: error: [GHC-58481]"
 #else
-          , "Foo.hs:6:1: error:"
+          [ "Foo.hs:6:1: error:"
 #endif
           , "    parse error (possibly incorrect indentation or mismatched brackets)"
-          ]
+#if __GLASGOW_HASKELL__ >= 910
+          , ""
+#endif
+          ])
 
   describe "expandDirs" $ do
     it "expands a directory" $ do
