Plumbum (latin for lead) is a port of Michael Snoyman's excellent conduit library.

It allows for production, transformation, and consumption of streams of data in constant memory. It can be used for processing files, dealing with network interfaces, or parsing structured data in an event-driven manner.

Large and possibly infinite streams can be processed in constant memory.

Chunks of data are dealt with lazily, one piece at a time, instead of needing to read in the entire body at once.

The resulting components are pure computations, and allow us to retain composability while dealing with the imperative world of I/O.

There are three main concepts:

A Source will produce a stream of data values and send them downstream. A Sink will consume a stream of data values from upstream and produce a return value. A Conduit will consume a stream of values from upstream and produces a new stream to send downstream.

In order to combine these different components, we have connecting and fusing. The connect method will combine a Source and Sink , feeding the values produced by the former into the latter, and producing a final result. Fusion, on the other hand, will take two components and generate a new component. For example, fusing a Conduit and Sink together into a new Sink , will consume the same values as the original Conduit and produce the same result as the original Sink .

There are four core primitives:

consume takes a single value from upstream, if available. produce sends a single value downstream. leftover puts a single value back in the upstream queue, ready to be read by the next call to consume . defer introduces a point of lazyiness, artifically deferring all further actions.