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

Next.Producer

Synopsis

Types

type Producer action item = Vendor (Const Void) (Next item) action Source #

A Vendor whose upstream interface is nothing and whose downstream interface is Next

type ProducerPlus up action item = Vendor up (Next item) action Source #

A Vendor whose downstream interface is Next

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

Examples

empty :: forall up item action. ProducerPlus up action item Source #

The empty stream

singleton :: forall up item action. Job up action item -> ProducerPlus up action item Source #

Yields one item, then stops

effect :: forall up action item. action item -> ProducerPlus up action item Source #

A single item obtained by performing an effect

each :: forall up foldable item action. Foldable foldable => foldable item -> ProducerPlus up action item Source #

Yields all the items from the given list

append :: forall up item action. ProducerPlus up action item -> ProducerPlus up action item -> ProducerPlus up action item Source #

Yields all the items of the first stream, followed by all the items of the second

unfoldPure :: forall state up item action. (state -> Step (item, state)) -> state -> ProducerPlus up action item Source #

unfoldEffect :: forall state up item action. (state -> action (Step (item, state))) -> state -> ProducerPlus up action item Source #

unfoldJob :: forall state up item action. (state -> Job up action (Step (item, state))) -> state -> ProducerPlus up action item Source #

State actions

null :: forall action item. Monad action => StateT (Producer action item) action Bool Source #

Test whether the state is an empty stream

head :: forall action item. Monad action => StateT (Producer action item) action (Step item) Source #

Peek at the first item in the stream state

pop :: forall action item. Monad action => StateT (Producer action item) action (Step item) Source #

Take the first item from the stream

push :: forall up action item. Monad action => item -> StateT (ProducerPlus up action item) action () Source #

Add an item to the front of the stream state