Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data InputStream a
- data OutputStream a
- makeInputStream :: MonadUnliftIO m => m (Maybe a) -> m (InputStream a)
- makeOutputStream :: MonadUnliftIO m => (Maybe a -> m ()) -> m (OutputStream a)
- read :: MonadUnliftIO m => InputStream a -> m (Maybe a)
- unRead :: MonadUnliftIO m => a -> InputStream a -> m ()
- peek :: MonadUnliftIO m => InputStream a -> m (Maybe a)
- write :: MonadUnliftIO m => Maybe a -> OutputStream a -> m ()
- writeTo :: MonadUnliftIO m => OutputStream a -> Maybe a -> m ()
- atEOF :: MonadUnliftIO m => InputStream a -> m Bool
- module UnliftIO.Streams.ByteString
- module UnliftIO.Streams.Combinators
- module UnliftIO.Streams.File
- module UnliftIO.Streams.List
- module UnliftIO.Streams.Text
Stream types
data InputStream a #
An InputStream
generates values of type c
in the IO
monad.
Two primitive operations are defined on InputStream
:
reads a value from the stream, where "end of stream" is signaled byread
::InputStream
c ->IO
(Maybe
c)read
returningNothing
.
"pushes back" a value to the stream.unRead
:: c ->InputStream
c ->IO
()
It is intended that InputStream
s obey the following law:
unRead
c stream >>read
stream ===return
(Just
c)
Instances
data OutputStream a #
An OutputStream
consumes values of type c
in the IO
monad.
The only primitive operation defined on OutputStream
is:
write
::Maybe
c ->OutputStream
c ->IO
()
Values of type c
are written in an OutputStream
by wrapping them in
Just
, and the end of the stream is indicated by supplying Nothing
.
If you supply a value after a Nothing
, the behavior is defined by the
implementer of the given OutputStream
. (All OutputStream
definitions in
this library will simply discard the extra input.)
Instances
Creating streams
makeInputStream :: MonadUnliftIO m => m (Maybe a) -> m (InputStream a) Source #
makeOutputStream :: MonadUnliftIO m => (Maybe a -> m ()) -> m (OutputStream a) Source #
Primitive stream operations
read :: MonadUnliftIO m => InputStream a -> m (Maybe a) Source #
unRead :: MonadUnliftIO m => a -> InputStream a -> m () Source #
peek :: MonadUnliftIO m => InputStream a -> m (Maybe a) Source #
write :: MonadUnliftIO m => Maybe a -> OutputStream a -> m () Source #
writeTo :: MonadUnliftIO m => OutputStream a -> Maybe a -> m () Source #
atEOF :: MonadUnliftIO m => InputStream a -> m Bool Source #
Batteries included
module UnliftIO.Streams.ByteString
module UnliftIO.Streams.Combinators
module UnliftIO.Streams.File
module UnliftIO.Streams.List
module UnliftIO.Streams.Text