Producer

org.specs2.control.producer.Producer
See theProducer companion object
case class Producer[F[_], A](run: F[LazyList[F, A]])(using evidence$1: Monad[F], evidence$2: Safe[F])

Simple streaming data structure for elements of type A and effects F

Attributes

Companion:
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Concrete methods

def >(p2: Producer[F, A]): Producer[F, A]

run the stream and add a finalizer to run finally

run the stream and add a finalizer to run finally

Attributes

def andFinally(finalizer: Finalizer): Producer[F, A]

run the stream and add a finalizer to run finally

run the stream and add a finalizer to run finally

Attributes

def append(other: Producer[F, A]): Producer[F, A]
def attempt: Producer[F, Either[Throwable, A]]

attempt to run each effect of the stream

attempt to run each effect of the stream

Attributes

def chunk(size: Int): Producer[F, A]

accumulate chunks of size n inside More nodes

accumulate chunks of size n inside More nodes

Attributes

def collect[B](pf: PartialFunction[A, B]): Producer[F, B]
def drop(n: Int): Producer[F, A]
def dropRight(n: Int): Producer[F, A]
def fill(n: Int): Producer[F, A]

REPEAT ELEMENTS

REPEAT ELEMENTS

Attributes

def filter(f: A => Boolean): Producer[F, A]
def first: Producer[F, A]
def flatMap[B](f: A => Producer[F, B]): Producer[F, B]

flatMap a Producer similar to how flatMap works on lists

flatMap a Producer similar to how flatMap works on lists

Attributes

def flatten[B](using ev: A <:< Producer[F, B]): Producer[F, B]
def flattenList[B](using ev: A <:< List[B]): Producer[F, B]

SPECIALIZED OPERATIONS BASED ON THE STREAM ELEMENTS

SPECIALIZED OPERATIONS BASED ON THE STREAM ELEMENTS

Attributes

def flattenSeq[B](using ev: A <:< Seq[B]): Producer[F, B]
def fold[B, S](start: F[S], f: (S, A) => F[S], end: S => F[B]): F[B]

run a stream with a Fold

run a stream with a Fold

Attributes

def fold[B](aFold: Fold[F, A, B]): F[B]

run a stream with a Fold

run a stream with a Fold

Attributes

def intersperse(in: A): Producer[F, A]

insert an element in between every element of the stream

insert an element in between every element of the stream

Attributes

def last: Producer[F, A]
def map[B](f: A => B): Producer[F, B]
def mapEval[B](f: A => F[B]): Producer[F, B]
def observe[S](start: F[S], f: (S, A) => S, onLastState: S => F[Unit]): Producer[F, A]

run some state changes on each element and run an action on the last state

run some state changes on each element and run an action on the last state

Attributes

def peek: F[(Option[A], Producer[F, A])]

produce the next element if there is one + the remaining of the stream

produce the next element if there is one + the remaining of the stream

Attributes

def peekN(n: Int): F[(List[A], Producer[F, A])]

produce the first n elements + the remaining of the stream

produce the first n elements + the remaining of the stream

Attributes

def pipe[B](t: (F, A) => B): Producer[F, B]

TRANSDUCER OPERATIONS

TRANSDUCER OPERATIONS

When it is easier to compose stream transformations

Attributes

def producerState[B, S](start: S, last: Option[S => Producer[F, B]])(f: (A, S) => (Producer[F, B], S)): Producer[F, B]

map the stream elements with a stateful function returning a full stream Then run one last function based on the latest state

map the stream elements with a stateful function returning a full stream Then run one last function based on the latest state

Attributes

def producerStateF[B, S](start: S, last: Option[S => Producer[F, B]])(f: (A, S) => F[(Producer[F, B], S)]): Producer[F, B]

map the stream elements with a stateful and effectful function returning a full stream Then run one last function based on the latest state

map the stream elements with a stateful and effectful function returning a full stream Then run one last function based on the latest state

Attributes

def receiveOption[B]: Producer[F, Option[A]]
def receiveOr[B](f: A => Producer[F, B])(or: => Producer[F, B]): Producer[F, B]
def reduce(f: (A, A) => A): Producer[F, A]

scan with a semigroup operation

scan with a semigroup operation

Attributes

def reduceMap[B](f: A => B)(using m: Monoid[B]): Producer[F, B]

map and scan with a Monoid operation

map and scan with a Monoid operation

Attributes

def reduceMapEval[B](f: A => F[B])(using m: Monoid[B]): Producer[F, B]

map with an effectful function and scan with a Monoid operation

map with an effectful function and scan with a Monoid operation

Attributes

def reduceMonoid(using s: Monoid[A]): Producer[F, A]

scan with a Monoid operation

scan with a Monoid operation

Attributes

def reduceSemigroup(using s: Semigroup[A]): Producer[F, A]

scan with a semigroup operation

scan with a semigroup operation

Attributes

def repeat: Producer[F, A]
def runLast: F[Option[A]]

get the last element

get the last element

Attributes

def runList: F[List[A]]

get all the elements as a List

get all the elements as a List

Attributes

def scan[B](start: B)(f: (B, A) => B): Producer[F, B]

run a stateful function on each element and stream the new state

run a stateful function on each element and stream the new state

Attributes

def scan1(f: (A, A) => A): Producer[F, A]

scan without an initial state

scan without an initial state

Attributes

def sequence[B](n: Int)(using ev: A <:< F[B]): Producer[F, B]
def sliding(size: Int): Producer[F, List[A]]

produce non overlapping windows of 'size' elements

produce non overlapping windows of 'size' elements

Attributes

def state[B, S](start: S)(f: (A, S) => (B, S)): Producer[F, B]

map the stream elements with a stateful function and return the mapped elements

map the stream elements with a stateful function and return the mapped elements

Attributes

def stateF[B, S](start: S)(f: (A, S) => (F[B], S)): Producer[F, F[B]]

map the stream elements with a stateful and effectful function

map the stream elements with a stateful and effectful function

Attributes

def take(n: Int): Producer[F, A]
def takeWhile(f: A => Boolean): Producer[F, A]
def zip[B](other: Producer[F, B]): Producer[F, (A, B)]

zip 2 streams together

zip 2 streams together

Attributes

def zipWithIndex: Producer[F, (A, Int)]

zip each element with its index in the stream

zip each element with its index in the stream

Attributes

def zipWithNext: Producer[F, (A, Option[A])]

zip each element with the next one in the stream (which will not exist for the last element)

zip each element with the next one in the stream (which will not exist for the last element)

Attributes

def zipWithNextN(n: Int): Producer[F, (A, List[A])]

zip each element with the next n elements in the stream which will not exist for the last element, but we take as many elements to fill the "next" list as we can

zip each element with the next n elements in the stream which will not exist for the last element, but we take as many elements to fill the "next" list as we can

Attributes

def zipWithPrevious: Producer[F, (Option[A], A)]

zip each element with the previous one in the stream (which will not exist for the first element)

zip each element with the previous one in the stream (which will not exist for the first element)

Attributes

def zipWithPreviousAndNext: Producer[F, (Option[A], A, Option[A])]

zip each element with the previous and next one in the stream (which will not exist for the first and last element

zip each element with the previous and next one in the stream (which will not exist for the first and last element

Attributes

def zipWithPreviousAndNextN(n: Int): Producer[F, (List[A], A, List[A])]

zip each element with the previous and next N elements in the stream

zip each element with the previous and next N elements in the stream

Attributes

def zipWithPreviousN(n: Int): Producer[F, (List[A], A)]

zip each element with the previous n elements in the stream which will not exist for the first element, but we take as many elements to fill the "previous" list as we can

zip each element with the previous n elements in the stream which will not exist for the first element, but we take as many elements to fill the "previous" list as we can

Attributes

def zipWithState[B](b: B)(f: (A, B) => B): Producer[F, (A, B)]

zip each element with a running state computed from a function

zip each element with a running state computed from a function

Attributes

def |>[B](t: (F, A) => B): Producer[F, B]

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product