Pull

final class Pull[+F[_], +O, +R] extends AnyVal

A p: Pull[F,O,R] reads values from one or more streams, returns a result of type R, and produces a Stream[F,O] when calling p.stream.

Any resources acquired by p are freed following the call to stream.

Laws:

Pull forms a monad in R with pure and flatMap:

  • pure >=> f == f
  • f >=> pure == f
  • (f >=> g) >=> h == f >=> (g >=> h) where f >=> g is defined as a => a flatMap f flatMap g

raiseError is caught by handleErrorWith:

  • handleErrorWith(raiseError(e))(f) == f(e)
Companion
object
class AnyVal
trait Matchable
class Any

Value members

Concrete methods

def >>[F2[x], O2 >: O, R2](p2: => Pull[F2, O2, R2]): Pull[F2, O2, R2]

Alias for flatMap(_ => p2).

Alias for flatMap(_ => p2).

def as[R2](r2: R2): Pull[F, O, R2]

Alias for _.map(_ => o2).

Alias for _.map(_ => o2).

def attempt: Pull[F, O, Either[Throwable, R]]

Returns a pull with the result wrapped in Right, or an error wrapped in Left if the pull has failed.

Returns a pull with the result wrapped in Right, or an error wrapped in Left if the pull has failed.

def covary[F2[x]]: Pull[F2, O, R]

Lifts this pull to the specified effect type.

Lifts this pull to the specified effect type.

def covaryAll[F2[x], O2 >: O, R2 >: R]: Pull[F2, O2, R2]

Lifts this pull to the specified effect type, output type, and resource type.

Lifts this pull to the specified effect type, output type, and resource type.

def covaryOutput[O2 >: O]: Pull[F, O2, R]

Lifts this pull to the specified output type.

Lifts this pull to the specified output type.

def covaryResource[R2 >: R]: Pull[F, O, R2]

Lifts this pull to the specified resource type.

Lifts this pull to the specified resource type.

def flatMap[F2[x], O2 >: O, R2](f: R => Pull[F2, O2, R2]): Pull[F2, O2, R2]

Applies the resource of this pull to f and returns the result.

Applies the resource of this pull to f and returns the result.

def handleErrorWith[F2[x], O2 >: O, R2 >: R](h: Throwable => Pull[F2, O2, R2]): Pull[F2, O2, R2]

If this terminates with Pull.raiseError(e), invoke h(e).

If this terminates with Pull.raiseError(e), invoke h(e).

def map[R2](f: R => R2): Pull[F, O, R2]

Applies the resource of this pull to f and returns the result in a new Pull.

Applies the resource of this pull to f and returns the result in a new Pull.

def mapOutput[O2](f: O => O2): Pull[F, O2, R]

Applies the outputs of this pull to f and returns the result in a new Pull.

Applies the outputs of this pull to f and returns the result in a new Pull.

def onComplete[F2[x], O2 >: O, R2 >: R](p2: => Pull[F2, O2, R2]): Pull[F2, O2, R2]

Run p2 after this, regardless of errors during this, then reraise any errors encountered during this.

Run p2 after this, regardless of errors during this, then reraise any errors encountered during this.

def stream(implicit ev: R <:< Unit): Stream[F, O]

Interpret this Pull to produce a Stream, introducing a scope.

Interpret this Pull to produce a Stream, introducing a scope.

May only be called on pulls which return a Unit result type. Use p.void.stream to explicitly ignore the result type of the pull.

def streamNoScope(implicit ev: R <:< Unit): Stream[F, O]

Interpret this Pull to produce a Stream without introducing a scope.

Interpret this Pull to produce a Stream without introducing a scope.

Only use this if you know a scope is not needed. Scope introduction is generally harmless and the risk of not introducing a scope is a memory leak in streams that otherwise would execute in constant memory.

May only be called on pulls which return a Unit result type. Use p.void.stream to explicitly ignore the result type of the pull.

def void: Pull[F, O, Unit]

Discards the result type of this pull.

Discards the result type of this pull.