Chaining Effects in a Generator with Effect.forEach

I'm wondering if when used inside a generator, would one expect the following to chain effects to execute properly? I'm trying to create a rule of thumb.

// sendEmail : Mail => Promise<void>
// emailsSent() : () => void
const f = Effect.gen(function*() { 
  ...
  yield* Effect.forEach(mails: Array<Mail>, (m) =>
    pipe(
      Effect.promise(() => sendEmail(m)),
      Effect.tap(metrics.emailSent()),
    ),
  )
}


I'm thinking that it should for the following reason.
In my function(m) => ...,
- it returns a single result that is an effect to be yielded..
- in pipe, the Effect.tap should chain with the previous promise.

(It's also interesting that I can't use yield* inside Effect.forEach without creating another Effect.gen)
Was this page helpful?