summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libraries/base/GHC/IO/Handle/Windows.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/libraries/base/GHC/IO/Handle/Windows.hs b/libraries/base/GHC/IO/Handle/Windows.hs
index 0666ce42e3..9fd1c54d49 100644
--- a/libraries/base/GHC/IO/Handle/Windows.hs
+++ b/libraries/base/GHC/IO/Handle/Windows.hs
@@ -217,9 +217,11 @@ handleToHANDLE :: Handle -> IO Win.HANDLE
handleToHANDLE h = case h of
FileHandle _ mv -> do
Handle__{haDevice = dev} <- readMVar mv
- case (cast dev :: Maybe (Win.Io Win.NativeHandle)) of
- Just hwnd -> return $ Win.toHANDLE hwnd
- Nothing -> throwErr "not a file HANDLE"
+ case (cast dev :: Maybe (Win.Io Win.NativeHandle),
+ cast dev :: Maybe (Win.Io Win.ConsoleHandle)) of
+ (Just hwnd, Nothing) -> return $ Win.toHANDLE hwnd
+ (Nothing, Just hwnd) -> return $ Win.toHANDLE hwnd
+ _ -> throwErr "not a file HANDLE"
DuplexHandle{} -> throwErr "not a file handle"
where
throwErr msg = ioException $ IOError (Just h)