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

Next.Pipe.Examples

Synopsis

Triviality

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

Does nothing at all

Predicates

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

Insertion

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

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.

Mapping

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

Concatenation

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

Flattens a stream of lists

Concat + map

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

Grouping

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, '.')]