Hyperlinkv0.8.0-beta.28

Stream

Stream.transformPullconsteffect/Stream.ts:642
<A, E, R, B, E2, R2, EX, RX>(
  self: Stream<A, E, R>,
  f: (
    pull: Pull.Pull<Arr.NonEmptyReadonlyArray<A>, E, void>,
    scope: Scope.Scope
  ) => Effect.Effect<
    Pull.Pull<Arr.NonEmptyReadonlyArray<B>, E2, void, R2>,
    EX,
    RX
  >
): Stream<B, EX | Pull.ExcludeDone<E2>, R | R2 | RX>

Derives a stream by transforming its pull effect.

Example (Transforming a pull effect)

import { Console, Effect, Stream } from "effect"

const stream = Stream.make(1, 2, 3)

const transformed = Stream.transformPull(stream, (pull) => Effect.succeed(pull))

const program = Effect.gen(function*() {
  const values = yield* Stream.runCollect(transformed)
  yield* Console.log(values)
})

Effect.runPromise(program)
// Output: [ 1, 2, 3 ]
constructors
Source effect/Stream.ts:64213 lines
export const transformPull = <A, E, R, B, E2, R2, EX, RX>(
  self: Stream<A, E, R>,
  f: (pull: Pull.Pull<Arr.NonEmptyReadonlyArray<A>, E, void>, scope: Scope.Scope) => Effect.Effect<
    Pull.Pull<Arr.NonEmptyReadonlyArray<B>, E2, void, R2>,
    EX,
    RX
  >
): Stream<B, EX | Pull.ExcludeDone<E2>, R | R2 | RX> =>
  fromChannel(
    Channel.fromTransform((_, scope) =>
      Effect.flatMap(Channel.toPullScoped(self.channel, scope), (pull) => f(pull as any, scope))
    )
  )
Referenced by 17 symbols