Core types and functions for the
- data InputStream c
- data OutputStream c
- makeInputStream :: IO (Maybe a) -> IO (InputStream a)
- makeOutputStream :: (Maybe a -> IO ()) -> IO (OutputStream a)
- read :: InputStream c -> IO (Maybe c)
- unRead :: c -> InputStream c -> IO ()
- peek :: InputStream c -> IO (Maybe c)
- write :: Maybe c -> OutputStream c -> IO ()
- atEOF :: InputStream a -> IO Bool
- connect :: InputStream a -> OutputStream a -> IO ()
- connectTo :: OutputStream a -> InputStream a -> IO ()
- supply :: InputStream a -> OutputStream a -> IO ()
- supplyTo :: OutputStream a -> InputStream a -> IO ()
- lockingInputStream :: InputStream a -> IO (InputStream a)
- lockingOutputStream :: OutputStream a -> IO (OutputStream a)
- nullInput :: IO (InputStream a)
- nullOutput :: IO (OutputStream a)
- data Generator r a
- fromGenerator :: Generator r a -> IO (InputStream r)
- yield :: r -> Generator r ()
Two primitive operations are defined on
reads a value from the stream, where "end of stream" is signaled by
"pushes back" a value to the stream.
unRead:: c ->
It is intended that
InputStreams obey the following law:
OutputStream from a value-consuming action.
makeOutputStream f) runs the computation
f on each value fed to it.
Primitive stream operations
Note that this could be used to add values back to the stream that were not originally drawn from the stream.
Connecting streams together
Thread safety / concurrency
Int] m = Streams.
fromGeneratorg >>= Streams.
toList-- value returned is [1,2,3]
As a general rule, you should not acquire resources that need to be freed
Generator, because there is no guarantee the coroutine continuation
will ever be called, nor can you catch an exception from within a