diff --git a/System/Console/ANSI/Windows/Foreign.hs b/System/Console/ANSI/Windows/Foreign.hs
--- a/System/Console/ANSI/Windows/Foreign.hs
+++ b/System/Console/ANSI/Windows/Foreign.hs
@@ -45,9 +45,11 @@
 
 import Foreign.StablePtr
 
-import GHC.IOBase (Handle(..), Handle__(..), FD)
+import GHC.IOBase (Handle(..), Handle__(..))
+import qualified GHC.IOBase as IOBase (FD) -- Just an Int32
 
 #if __GLASGOW_HASKELL__ >= 612
+import GHC.IO.FD (FD(..)) -- A wrapper around an Int32
 import Data.Typeable
 #endif
 
@@ -285,7 +287,7 @@
 
 
 -- This essential function comes from msvcrt.  It's OK to depend on msvcrt since GHC's base package does.
-foreign import ccall unsafe "_get_osfhandle" cget_osfhandle :: FD -> IO HANDLE
+foreign import ccall unsafe "_get_osfhandle" cget_osfhandle :: IOBase.FD -> IO HANDLE
 
 -- | This bit is all highly dubious.  The problem is that we want to output ANSI to arbitrary Handles rather than forcing
 -- people to use stdout.  However, the Windows ANSI emulator needs a Windows HANDLE to work it's magic, so we need to be able
@@ -307,7 +309,8 @@
 #if __GLASGOW_HASKELL__ < 612
         fd <- fmap haFD $ readMVar write_handle_mvar
 #else
-        Just fd <- fmap (\(Handle__ { haDevice = dev }) -> cast dev) $ readMVar write_handle_mvar
+        --readMVar write_handle_mvar >>= \(Handle__ { haDevice = dev }) -> print (typeOf dev)
+        Just fd <- fmap (\(Handle__ { haDevice = dev }) -> fmap fdFD (cast dev)) $ readMVar write_handle_mvar
 #endif
 
         -- Finally, turn that (C-land) FD into a HANDLE using msvcrt
diff --git a/ansi-terminal.cabal b/ansi-terminal.cabal
--- a/ansi-terminal.cabal
+++ b/ansi-terminal.cabal
@@ -1,5 +1,5 @@
 Name:                ansi-terminal
-Version:             0.5.1
+Version:             0.5.2
 Cabal-Version:       >= 1.2
 Category:            User Interfaces
 Synopsis:            Simple ANSI terminal support, with Windows compatibility
@@ -73,7 +73,7 @@
                 Other-Modules:          System.Console.ANSI.Unix
         
         if flag(splitBase)
-                Build-Depends:          base >= 3
+                Build-Depends:          base >= 3 && < 5
         else
                 Build-Depends:          base < 3
         
