Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- data ReaderError = ReaderGetError {}
- data Reader
- newReader :: Handle -> IO Reader
- data Writer
- newWriter :: Handle -> Writer
- data Duplex
- newDuplex :: Handle -> IO Duplex
- class CanGet r where
- read :: (CanGet r, Binary a) => r -> IO a
- readWith :: (CanGet r, Binary a) => r -> (a -> IO b) -> IO b
- class CanPut w where
- write :: (CanPut w, Binary a) => w -> a -> IO ()
Readers
data ReaderError Source #
An error that can occur during reading
Since: 0.0.1
ReaderGetError | Error from the |
|
Instances
Show ReaderError Source # | |
Defined in Data.Binary.IO showsPrec :: Int -> ReaderError -> ShowS # show :: ReaderError -> String # showList :: [ReaderError] -> ShowS # | |
Exception ReaderError Source # | |
Defined in Data.Binary.IO |
Since: 0.0.1
Create a new reader.
Reading using the Reader
may throw ReaderError
.
The internal position of the Reader
is not advanced when it throws an exception during reading.
This has the consequence that if you're trying to read with the same faulty Get
operation multiple times, you will always receive an exception. The same is true for follow-up
actions when using readWith
.
Other threads reading from the Handle
will interfere with read operations of the Reader
.
However, the Reader
itself is thread-safe and can be utilized concurrently.
Once the Handle
reaches EOF, it will be closed.
The given Handle
will be swiched to binary mode via hSetBinaryMode
.
Since: 0.0.1
Writers
Since: 0.0.1
Duplex
Classes
r
can execute Get
operations
Since: 0.0.1
Read something from r
and perform an IO
action with it.
If the given action throws an exception, the read is not considered successful and will not advance the underlying read source.
Keep in mind, long running actions on a
will block other threads when they try to read the from
the same source r
.
Since: 0.0.1
w
can execute Put
operations
Since: 0.0.1