supply-next-0.0.1.2: Supply-chain interface for basic streaming
Safe HaskellSafe-Inferred
LanguageGHC2021

Next.Pipe

Synopsis

Types

type Pipe action item1 item2 = Vendor (Next item1) (Next item2) action Source #

A Vendor whose upstream and downstream interfaces are both Next

type PipePlus up action item1 item2 = TerminableStream item1 up => Vendor up (Next item2) action Source #

Like Pipe, but with a more general upstream interface which can be anything in the TerminableStream class

This type is like Pipe except that it has an extra type parameter representing the upstream interface, hence its name is "pipe plus".

Examples

cons Source #

Arguments

:: forall item action up. Job up action item

This job produces an item to add to the front of the list

-> PipePlus up action item item 

Add one item to the beginning of a stream

map Source #

Arguments

:: forall item1 item2 action up. (item1 -> Job up action item2)

For each input item, this job produces an output item

-> PipePlus up action item1 item2 

Apply a function to each item in the stream

concat :: forall item action up. PipePlus up action [item] item Source #

Flattens a stream of lists

takeWhile Source #

Arguments

:: forall item action up. (item -> Job up action Bool)

True if this is the sort of thing we'd like to keep

-> PipePlus up action item item 

Yields the longest prefix matching the predicate and discards the rest

dropWhile Source #

Arguments

:: forall item action up. (item -> Job up action Bool)

True if this is the sort of thing we'd like to get rid of

-> PipePlus up action item item 

Discards the longest prefix matching the predicate and yields the rest

group :: forall up item action. Eq item => PipePlus up action item (Positive, item) Source #

Removes consecutive duplicate items, and yields each item along with the size of the repetition

For example, "Hrmm..." groups into [(1, 'H'), (1, 'r'), (2, 'm'), (3, '.')]

intersperse Source #

Arguments

:: forall item action up. Job up action item

This job generates items that will be inserted in between the items of the original list

-> PipePlus up action item item 

Add an item between each pair of items of a stream

The length of the stream is modified as \case{ 0 -> 0; n -> (2 * n) - 1 }.

beforeEach Source #

Arguments

:: forall item action up. Job up action item

This job generates items that will be inserted before each of the items of the original list

-> PipePlus up action item item 

Add an item before each item in a stream

The length of the stream is doubled.

id :: forall up item action. PipePlus up action item item Source #

Does nothing at all

concatMapJob Source #

Arguments

:: forall item1 item2 action up. (item1 -> Job up action [item2])

For each input item, this job produces any number of output items

-> PipePlus up action item1 item2 

Applies the function to each result obtained from upstream, and yields each result from the list to the downstream

concatMapProducer Source #

Arguments

:: forall item1 item2 action. (item1 -> Producer action item2)

For each item from the input list, this vendor generates any number of actions to yield in the resulting list

-> Pipe action item1 item2 

Like concatMapJob, but the function gives a Producer instead of a Job