Producer

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

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

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

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

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

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

accumulate chunks of size n inside More nodes

accumulate chunks of size n inside More nodes

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

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

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

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

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

run a stream with a Fold

run a stream with a Fold

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

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

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

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

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

TRANSDUCER OPERATIONS

TRANSDUCER OPERATIONS

When it is easier to compose stream transformations

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

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

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

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

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

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

scan with a Monoid operation

scan with a Monoid operation

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

scan with a semigroup operation

scan with a semigroup operation

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

get the last element

get the last element

def runList: F[List[A]]

get all the elements as a List

get all the elements as a List

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

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

scan without an initial state

scan without an initial state

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

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

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

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

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

zip each element with its index in the stream

zip each element with its index in the stream

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)

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

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)

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

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

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

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

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

Inherited methods

def productElementNames: Iterator[String]
Inherited from:
Product
def productIterator: Iterator[Any]
Inherited from:
Product