diff --git a/src/System/Console/Terminal/Posix.hsc b/src/System/Console/Terminal/Posix.hsc index ebca398..204b739 100644 --- a/src/System/Console/Terminal/Posix.hsc +++ b/src/System/Console/Terminal/Posix.hsc @@ -4,15 +4,13 @@ module System.Console.Terminal.Posix ( size, fdSize, hSize ) where +import System.IO (Handle) +import System.IO.OS (withFileDescriptorReadingBiasedRaw) import System.Console.Terminal.Common import Control.Exception (catch) -import Data.Typeable (cast) import Foreign import Foreign.C.Error import Foreign.C.Types -import GHC.IO.FD (FD(FD, fdFD)) -import GHC.IO.Handle.Internals (withHandle_) -import GHC.IO.Handle.Types (Handle, Handle__(Handle__, haDevice)) #if defined(__GLASGOW_HASKELL__) && (__GLASGOW_HASKELL__ < 706) import Prelude hiding (catch) #endif @@ -59,7 +57,4 @@ size :: Integral n => IO (Maybe (Window n)) size = fdSize (Fd (#const STDOUT_FILENO)) hSize :: Integral n => Handle -> IO (Maybe (Window n)) -hSize h = withHandle_ "hSize" h $ \Handle__ { haDevice = dev } -> - case cast dev of - Nothing -> return Nothing - Just FD { fdFD = fd } -> fdSize (Fd fd) +hSize h = withFileDescriptorReadingBiasedRaw h $ fdSize . Fd