Hoogle Search
Within LTS Haskell 24.68 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
liftReaderT :: forall (m :: Type -> Type) e a . Monad m => ReaderT e m a -> StateT e m aunification-fd Control.Monad.State.UnificationExtras Lift a reader into a state monad. More particularly, this allows disabling mutability in a local context within StateT.
fdPread :: Fd -> ByteCount -> FileOffset -> IO ByteStringunix-bytestring System.Posix.IO.ByteString.Ext Read data from a specified position in the Fd and convert it to a ByteString, without altering the position stored in the Fd. Throws an exception if this is an invalid descriptor, or EOF has been reached. This is essentially equivalent to fdPreadBuf; the differences are that we allocate a byte buffer for the ByteString, and that we detect EOF and throw an IOError. Since: 0.3.0
fdPreadBuf :: Fd -> Ptr Word8 -> ByteCount -> FileOffset -> IO ByteCountunix-bytestring System.Posix.IO.ByteString.Ext Read data from a specified position in the Fd into memory, without altering the position stored in the Fd. This is exactly equivalent to the XPG4.2 pread(2) system call, except that we return 0 bytes read if the Int argument is less than or equal to zero (instead of throwing an errno exception). If there are any errors, then they are thrown as IOError exceptions. Since: 0.3.0
fdPreads :: (ByteCount -> a -> Maybe a) -> a -> Fd -> ByteCount -> FileOffset -> IO ByteStringunix-bytestring System.Posix.IO.ByteString.Ext Read data from a specified position in the Fd and convert it to a ByteString, without altering the position stored in the Fd. Throws an exception if this is an invalid descriptor, or EOF has been reached. This is a fdPreadBuf based version of fdReads; see those functions for more details. Since: 0.3.1
fdRead :: Fd -> ByteCount -> IO ByteStringunix-bytestring System.Posix.IO.ByteString.Ext Read data from an Fd and convert it to a ByteString. Throws an exception if this is an invalid descriptor, or EOF has been reached. This is essentially equivalent to fdReadBuf; the differences are that we allocate a byte buffer for the ByteString, and that we detect EOF and throw an IOError.
fdReadBuf :: Fd -> Ptr Word8 -> ByteCount -> IO ByteCountunix-bytestring System.Posix.IO.ByteString.Ext Read data from an Fd into memory. This is exactly equivalent to the POSIX.1 read(2) system call, except that we return 0 bytes read if the ByteCount argument is less than or equal to zero (instead of throwing an errno exception). N.B., this behavior is different from the version in unix-2.4.2.0 which only checks for equality to zero. If there are any errors, then they are thrown as IOError exceptions. Since: 0.3.0
fdReads :: (ByteCount -> a -> Maybe a) -> a -> Fd -> ByteCount -> IO ByteStringunix-bytestring System.Posix.IO.ByteString.Ext Read data from an Fd and convert it to a ByteString. Throws an exception if this is an invalid descriptor, or EOF has been reached. This version takes a kind of stateful predicate for whether and how long to keep retrying. Assume the function is called as fdReads f z0 fd n0. We will attempt to read n0 bytes from fd. If we fall short, then we will call f len z where len is the total number of bytes read so far and z is the current state (initially z0). If it returns Nothing then we will give up and return the current buffer; otherwise we will retry with the new state, continuing from where we left off. For example, to define a function that tries up to n times, we can use:
fdReadUptoNTimes :: Int -> Fd -> ByteCount -> IO ByteString fdReadUptoNTimes n0 = fdReads retry n0 where retry _ 0 = Nothing retry _ n = Just $! n-1
The benefit of doing this instead of the naive approach of calling fdRead repeatedly is that we only need to allocate one byte buffer, and trim it once at the end--- whereas the naive approach would allocate a buffer, trim it to the number of bytes read, and then concatenate with the previous one (another allocation, plus copying everything over) for each time around the loop. Since: 0.2.1fdReadvBuf :: Fd -> Ptr CIovec -> Int -> IO ByteCountunix-bytestring System.Posix.IO.ByteString.Ext Read data from an Fd and scatter it into memory. This is exactly equivalent to the XPG4.2 readv(2) system call, except that we return 0 bytes read if the Int argument is less than or equal to zero (instead of throwing an eINVAL exception). If there are any errors, then they are thrown as IOError exceptions. TODO: better documentation. Since: 0.3.0
tryFdPreadBuf :: Fd -> Ptr Word8 -> ByteCount -> FileOffset -> IO (Either Errno ByteCount)unix-bytestring System.Posix.IO.ByteString.Ext Read data from a specified position in the Fd into memory, without altering the position stored in the Fd. This is a variation of fdPreadBuf which returns errors with an Either instead of throwing exceptions. Since: 0.3.3
tryFdReadBuf :: Fd -> Ptr Word8 -> ByteCount -> IO (Either Errno ByteCount)unix-bytestring System.Posix.IO.ByteString.Ext Read data from an Fd into memory. This is a variation of fdReadBuf which returns errors with an Either instead of throwing exceptions. Since: 0.3.3