Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make ZStream.Take easier to use #3653

@iravid

Description

@iravid

Take is a type alias for Exit[Option[E], Chunk[A]]. This represents a step in a stream:

  • Exit.succeed(Chunk) is an emission of a chunk;
  • Exit.fail(Some(E)) is a stream failure;
  • Exit.fail(None) is an end-of-stream;
  • Exit.halt(Die/Interrupt) are defects as usual.

In this ticket, we will convert it to the following form:

case class Take[E, A](exit: Exit[Option[E], Chunk[A]]) extends AnyVal

And provide the following facilities:

  • An object with common constructors that forward to Exit constructors with adapations to the error/value types:
    • Take.succeed(A)
    • Take.succeed(Chunk[A])
    • Take.fail(E)
    • Take.halt(Cause[E])
    • Take.end
    • Take.die(Throwable)
    • Take.dieMessage(String)
    • Take.done(Exit[E, A])
  • Folds for deconstructing Take values:
def fold[R, E, Z](end: => Z, error: Cause[E] => Z, value: Chunk[A] => Z): Z
def foldM[R, E1, Z](end: => ZIO[R, E1, Z], error: Cause[E] => ZIO[R, E1, Z], value: Chunk[A] => ZIO[R, E1, Z]): ZIO[R, E1, Z]
  • The minimal subset of combinators required to port ZStream from using Exit directly to using Take

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions