Eval is a Pull constructor for embedding an effectful computation that produces a result without emitting output elements. Its type, Eval[F, R], extends Pull[F, Nothing, R], so it can appear wherever a result-producing Pull is expected. section 15.3
Interpreting an Eval
When Pull is stepped with a Monad[F], an Eval(action) case maps the action’s result into a completed computation: action.map(Left(_)). Result therefore signals completion, while Eval performs the effect needed to obtain that result. section 15.3
Eval supports several layers of the Pull and Stream interface:
- uncons represents stepping through a Pull by wrapping its effectful step result in Eval. section 15.3
- Stream.eval, mapEval, and unfoldEval lift effectful values or effectful generation into streams. section 15.3
enum Pull[+F[_], +O, +R]:
case Result[+R](result: R) extends Pull[Nothing, Nothing, R]
case Output[+O](value: O) extends Pull[Nothing, O, Unit]
case Eval[+F[_], R](action: F[R]) extends Pull[F, Nothing, R]
case FlatMap[+F[_], X, +O, +R](
source: Pull[F, O, X], f: X => Pull[F, O, R]) extends Pull[F, O, R]
Use the Pull definition to compare Eval with Result, Output, and FlatMap, including each constructor’s effect, output, and result types. section 15.3
