summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2022-05-28 00:27:15 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-06-18 10:43:34 -0400
commit31c214cc9d3873b7d1bf4751700cc6c7da09e11d (patch)
treee65f07d6af4dd64acdabc58e3fa5f4502ea0fdfa
parentcadd775397a88889bb6be6aca34469eea8ba17ec (diff)
downloadhaskell-31c214cc9d3873b7d1bf4751700cc6c7da09e11d.tar.gz
winio: Add support to console handles to handleToHANDLE
-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)