+{-# LANGUAGE NoImplicitPrelude
+ , RecordWildCards
+ , BangPatterns
+ , PatternGuards
+ , NondecreasingIndentation
+ , Rank2Types
+ #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_HADDOCK hide #-}
-{-# LANGUAGE NoImplicitPrelude, RecordWildCards, BangPatterns #-}
-----------------------------------------------------------------------------
-- |
wantWritableHandle fun h@(FileHandle _ m) act
= wantWritableHandle' fun h m act
wantWritableHandle fun h@(DuplexHandle _ _ m) act
- = withHandle_' fun h m act
+ = wantWritableHandle' fun h m act
+ -- we know it's not a ReadHandle or ReadWriteHandle, but we have to
+ -- check for ClosedHandle/SemiClosedHandle. (#4808)
wantWritableHandle'
:: String -> Handle -> MVar Handle__
wantReadableHandle_ fun h@(FileHandle _ m) act
= wantReadableHandle' fun h m act
wantReadableHandle_ fun h@(DuplexHandle _ m _) act
- = withHandle_' fun h m act
+ = wantReadableHandle' fun h m act
+ -- we know it's not a WriteHandle or ReadWriteHandle, but we have to
+ -- check for ClosedHandle/SemiClosedHandle. (#4808)
wantReadableHandle'
:: String -> Handle -> MVar Handle__
-- using an 8k char buffer instead of 32k improved performance for a
-- basic "cat" program by ~30% for me. --SDM
dEFAULT_CHAR_BUFFER_SIZE :: Int
-dEFAULT_CHAR_BUFFER_SIZE = dEFAULT_BUFFER_SIZE `div` 4
+dEFAULT_CHAR_BUFFER_SIZE = 2048 -- 8k/sizeof(HsChar)
getCharBuffer :: IODevice dev => dev -> BufferState
-> IO (IORef CharBuffer, BufferMode)