diff --git a/Control/Concurrent/Raw.hs b/Control/Concurrent/Raw.hs
--- a/Control/Concurrent/Raw.hs
+++ b/Control/Concurrent/Raw.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE NoImplicitPrelude, MagicHash, UnboxedTuples #-}
+{-# LANGUAGE CPP, NoImplicitPrelude, MagicHash, UnboxedTuples #-}
 
 module Control.Concurrent.Raw ( rawForkIO, rawForkOn ) where
 
@@ -12,10 +12,18 @@
 -- exception handler.
 {-# INLINE rawForkIO #-}
 rawForkIO :: IO () -> IO ThreadId
+#if MIN_VERSION_base(4,17,0)
+rawForkIO (IO action) = IO $ \s ->
+#else
 rawForkIO action = IO $ \s ->
+#endif
    case (fork# action s) of (# s1, tid #) -> (# s1, ThreadId tid #)
 
 {-# INLINE rawForkOn #-}
 rawForkOn :: Int -> IO () -> IO ThreadId
+#if MIN_VERSION_base(4,17,0)
+rawForkOn (I# cpu) (IO action) = IO $ \s ->
+#else
 rawForkOn (I# cpu) action = IO $ \s ->
+#endif
    case (forkOn# cpu action s) of (# s1, tid #) -> (# s1, ThreadId tid #)
diff --git a/test/test.hs b/test/test.hs
--- a/test/test.hs
+++ b/test/test.hs
@@ -205,10 +205,10 @@
 wrapOn_0 = wrap $ ThreadGroup.forkOn 0
 
 wrapIOWithUnmask :: (Fork a -> IO b) -> IO b
-wrapIOWithUnmask = wrap $ \tg m -> ThreadGroup.forkIOWithUnmask tg $ const m
+wrapIOWithUnmask = wrap $ \tg m -> ThreadGroup.forkIOWithUnmask tg (\_ -> m)
 
 wrapOnWithUnmask :: (Fork a -> IO b) -> IO b
-wrapOnWithUnmask = wrap $ \tg m -> ThreadGroup.forkOnWithUnmask 0 tg $ const m
+wrapOnWithUnmask = wrap $ \tg m -> ThreadGroup.forkOnWithUnmask 0 tg (\_ -> m)
 
 wrap :: (ThreadGroup -> Fork a) -> (Fork a -> IO b) -> IO b
 wrap doFork test = ThreadGroup.new >>= test . doFork
diff --git a/threads.cabal b/threads.cabal
--- a/threads.cabal
+++ b/threads.cabal
@@ -1,5 +1,5 @@
 name:          threads
-version:       0.5.1.6
+version:       0.5.1.7
 cabal-version: >= 1.9.2
 build-type:    Custom
 stability:     experimental
@@ -44,18 +44,20 @@
   GHC==7.6.3,
   GHC==7.8.4,
   GHC==7.10.2,
-  GHC==8.0.1
+  GHC==8.0.1,
+  GHC==9.4.1
 
 source-repository head
   Type: git
   Location: git://github.com/basvandijk/threads.git
 
 custom-setup
-    setup-depends: base >= 4.4 && < 5, Cabal >= 1.12
+    setup-depends: base >= 4.4 && < 5, Cabal >= 1.12 && < 3.9
 
 -------------------------------------------------------------------------------
 
 library
+  default-language: Haskell2010
   build-depends: base >= 4.4 && < 5
                , stm  >= 2.1
   exposed-modules: Control.Concurrent.Thread
@@ -66,6 +68,7 @@
 -------------------------------------------------------------------------------
 
 test-suite test-threads
+  default-language: Haskell2010
   type:           exitcode-stdio-1.0
   hs-source-dirs: test
   main-is:        test.hs
