diff --git a/alex.cabal b/alex.cabal
--- a/alex.cabal
+++ b/alex.cabal
@@ -1,5 +1,5 @@
 name: alex
-version: 2.3
+version: 2.3.1
 license: BSD3
 license-file: LICENSE
 copyright: (c) Chis Dornan, Simon Marlow
diff --git a/src/Main.hs b/src/Main.hs
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -22,6 +22,9 @@
 import Paths_alex ( version, getDataDir )
 
 import Control.Exception as Exception ( block, unblock, catch, throw )
+#if __GLASGOW_HASKELL__ >= 610
+import Control.Exception ( bracketOnError )
+#endif
 import Control.Monad ( when, liftM )
 import Data.Char ( chr )
 import Data.List ( isSuffixOf )
@@ -303,6 +306,7 @@
 dieAlex :: String -> IO a
 dieAlex s = getProgramName >>= \prog -> die (prog ++ ": " ++ s)
 
+#if __GLASGOW_HASKELL__ < 610
 bracketOnError
 	:: IO a		-- ^ computation to run first (\"acquire resource\")
 	-> (a -> IO b)  -- ^ computation to run last (\"release resource\")
@@ -316,3 +320,4 @@
 	   (\e -> do { after a; throw e })
     return r
  )
+#endif
