Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
A sink consumes a stream of data, and produces a result. A sink must always produce a result, and must always produce a single result. This is encoded in the types themselves.
There is a Monad instance for sink, making it simple to compose multiple sinks
together into a larger sink. You can also use the built-in sink functions to perform most of your
work. Like sources, you’ll rarely need to dive into the inner workings. Let’s start off with an
example: getting lines from a stream of Chars (we’ll assume Unix line endings
for simplicity).
importData.ConduitimportqualifiedData.Conduit.ListasCL-- Get a single line from the stream.sinkLine::Resourcem=>SinkCharmStringsinkLine=sinkStateid-- initial state, nothing at the beginning of the line