FlatMap

sealed abstract class FlatMap[A] extends Eval[A]

FlatMap is a type of Eval[A] that is used to chain computations involving .map and .flatMap. Along with Eval#flatMap it implements the trampoline that guarantees stack-safety.

FlatMap is a type of Eval[A] that is used to chain computations involving .map and .flatMap. Along with Eval#flatMap it implements the trampoline that guarantees stack-safety.

Users should not instantiate FlatMap instances themselves. Instead, they will be automatically created when needed.

Unlike a traditional trampoline, the internal workings of the trampoline are not exposed. This allows a slightly more efficient implementation of the .value method.

class Eval[A]
trait Serializable
class Object
trait Matchable
class Any

Type members

Types

type Start

Value members

Concrete methods

def memoize: Eval[A]
def value: A

Inherited methods

def flatMap[B](f: A => Eval[B]): Eval[B]

Lazily perform a computation based on an Eval[A], using the function f to produce an Eval[B] given an A.

Lazily perform a computation based on an Eval[A], using the function f to produce an Eval[B] given an A.

This call is stack-safe -- many .flatMap calls may be chained without consumed additional stack during evaluation. It is also written to avoid left-association problems, so that repeated calls to .flatMap will be efficiently applied.

Computation performed in f is always lazy, even when called on an eager (Now) instance.

Inherited from
Eval
def map[B](f: A => B): Eval[B]

Transform an Eval[A] into an Eval[B] given the transformation function f.

Transform an Eval[A] into an Eval[B] given the transformation function f.

This call is stack-safe -- many .map calls may be chained without consumed additional stack during evaluation.

Computation performed in f is always lazy, even when called on an eager (Now) instance.

Inherited from
Eval

Abstract fields

val run: Start => Eval[A]
val start: () => Eval[Start]