Rename readExactly to read

This commit is contained in:
Victor Denisov 2016-05-01 19:05:51 -07:00
parent 73dfdb0b7f
commit 655f4b90bc
3 changed files with 5 additions and 5 deletions

View file

@ -16,7 +16,7 @@ import System.IO
-- --
-- `read` should return `ByteString.null` on EOF -- `read` should return `ByteString.null` on EOF
data Connection = Connection { data Connection = Connection {
readExactly :: Int -> IO ByteString, read :: Int -> IO ByteString,
write :: ByteString -> IO (), write :: ByteString -> IO (),
flush :: IO (), flush :: IO (),
close :: IO ()} close :: IO ()}
@ -25,7 +25,7 @@ fromHandle :: Handle -> IO Connection
-- ^ Make connection form handle -- ^ Make connection form handle
fromHandle handle = do fromHandle handle = do
return Connection return Connection
{ readExactly = ByteString.hGet handle { read = ByteString.hGet handle
, write = ByteString.hPut handle , write = ByteString.hPut handle
, flush = hFlush handle , flush = hFlush handle
, close = hClose handle , close = hClose handle

View file

@ -207,8 +207,8 @@ readMessage :: Connection -> IO Response
-- ^ read response from a connection -- ^ read response from a connection
readMessage conn = readResp where readMessage conn = readResp where
readResp = do readResp = do
len <- fromEnum . decodeSize . L.fromStrict <$> Connection.readExactly conn 4 len <- fromEnum . decodeSize . L.fromStrict <$> Connection.read conn 4
runGet getReply . L.fromStrict <$> Connection.readExactly conn len runGet getReply . L.fromStrict <$> Connection.read conn len
decodeSize = subtract 4 . runGet getInt32 decodeSize = subtract 4 . runGet getInt32
type FullCollection = Text type FullCollection = Text

View file

@ -56,7 +56,7 @@ tlsConnection :: TLS.Context -> IO () -> IO Connection
tlsConnection ctx close = do tlsConnection ctx close = do
restRef <- newIORef mempty restRef <- newIORef mempty
return Connection return Connection
{ Connection.readExactly = \count -> let { Connection.read = \count -> let
readSome = do readSome = do
rest <- readIORef restRef rest <- readIORef restRef
writeIORef restRef mempty writeIORef restRef mempty