conduit-0.5.0: Streaming data processing library.

Safe HaskellSafe-Infered

Data.Conduit.Util

Contents

Description

Utility functions from older versions of conduit. These should be considered deprecated, as there are now easier ways to handle their use cases. This module is provided solely for backwards compatibility.

Synopsis

Source

sourceStateSource

Arguments

:: Monad m 
=> state

Initial state

-> (state -> m (SourceStateResult state output))

Pull function

-> Source m output 

Construct a Source with some stateful functions. This function addresses threading the state value for you.

Since 0.3.0

sourceStateIOSource

Arguments

:: MonadResource m 
=> IO state

resource and/or state allocation

-> (state -> IO ())

resource and/or state cleanup

-> (state -> m (SourceStateResult state output))

Pull function. Note that this need not explicitly perform any cleanup.

-> Source m output 

A combination of sourceIO and sourceState.

Since 0.3.0

data SourceStateResult state output Source

The return value when pulling in the sourceState function. Either indicates no more data, or the next value and an updated state.

Since 0.3.0

Constructors

StateOpen state output 
StateClosed 

sourceIOSource

Arguments

:: MonadResource m 
=> IO state

resource and/or state allocation

-> (state -> IO ())

resource and/or state cleanup

-> (state -> m (SourceIOResult output))

Pull function. Note that this should not perform any cleanup.

-> Source m output 

Construct a Source based on some IO actions for alloc/release.

Since 0.3.0

data SourceIOResult output Source

The return value when pulling in the sourceIO function. Either indicates no more data, or the next value.

Since 0.3.0

Constructors

IOOpen output 
IOClosed 

Sink

sinkStateSource

Arguments

:: Monad m 
=> state

initial state

-> (state -> input -> m (SinkStateResult state input output))

push

-> (state -> m output)

Close. Note that the state is not returned, as it is not needed.

-> Sink input m output 

Construct a Sink with some stateful functions. This function addresses threading the state value for you.

Since 0.3.0

data SinkStateResult state input output Source

A helper type for sinkState, indicating the result of being pushed to. It can either indicate that processing is done, or to continue with the updated state.

Since 0.3.0

Constructors

StateDone (Maybe input) output 
StateProcessing state 

sinkIOSource

Arguments

:: MonadResource m 
=> IO state

resource and/or state allocation

-> (state -> IO ())

resource and/or state cleanup

-> (state -> input -> m (SinkIOResult input output))

push

-> (state -> m output)

close

-> Sink input m output 

Construct a Sink. Note that your push and close functions need not explicitly perform any cleanup.

Since 0.3.0

data SinkIOResult input output Source

A helper type for sinkIO, indicating the result of being pushed to. It can either indicate that processing is done, or to continue.

Since 0.3.0

Constructors

IODone (Maybe input) output 
IOProcessing 

Conduit

haveMoreSource

Arguments

:: Conduit a m b

The next Conduit to return after the list has been exhausted.

-> m ()

A close action for early termination.

-> [b]

The values to send down the stream.

-> Conduit a m b 

A helper function for returning a list of values from a Conduit.

Since 0.3.0

conduitStateSource

Arguments

:: Monad m 
=> state

initial state

-> (state -> input -> m (ConduitStateResult state input output))

Push function.

-> (state -> m [output])

Close function. The state need not be returned, since it will not be used again.

-> Conduit input m output 

Construct a Conduit with some stateful functions. This function addresses threading the state value for you.

Since 0.3.0

data ConduitStateResult state input output Source

A helper type for conduitState, indicating the result of being pushed to. It can either indicate that processing is done, or to continue with the updated state.

Since 0.3.0

Constructors

StateFinished (Maybe input) [output] 
StateProducing state [output] 

Instances

Functor (ConduitStateResult state input) 

conduitIOSource

Arguments

:: MonadResource m 
=> IO state

resource and/or state allocation

-> (state -> IO ())

resource and/or state cleanup

-> (state -> input -> m (ConduitIOResult input output))

Push function. Note that this need not explicitly perform any cleanup.

-> (state -> m [output])

Close function. Note that this need not explicitly perform any cleanup.

-> Conduit input m output 

Construct a Conduit.

Since 0.3.0

data ConduitIOResult input output Source

A helper type for conduitIO, indicating the result of being pushed to. It can either indicate that processing is done, or to continue.

Since 0.3.0

Constructors

IOFinished (Maybe input) [output] 
IOProducing [output] 

Instances

Sequencing

type SequencedSink state input m output = state -> Sink input m (SequencedSinkResponse state input m output)Source

Helper type for constructing a Conduit based on Sinks. This allows you to write higher-level code that takes advantage of existing conduits and sinks, and leverages a sink's monadic interface.

Since 0.3.0

sequenceSinkSource

Arguments

:: Monad m 
=> state

initial state

-> SequencedSink state input m output 
-> Conduit input m output 

Convert a SequencedSink into a Conduit.

Since 0.3.0

data SequencedSinkResponse state input m output Source

Return value from a SequencedSink.

Since 0.3.0

Constructors

Emit state [output]

Set a new state, and emit some new output.

Stop

End the conduit.

StartConduit (Conduit input m output)

Pass control to a new conduit.

Misc

zip :: Monad m => Source m a -> Source m b -> Source m (a, b)Source

Combines two sources. The new source will stop producing once either source has been exhausted.

Since 0.3.0

zipSinks :: Monad m => Sink i m r -> Sink i m r' -> Sink i m (r, r')Source

Combines two sinks. The new sink will complete when both input sinks have completed.

Any leftovers are discarded.

Since 0.4.1