Effect CommunityEC
Effect Community3y ago
5 replies
Nomadin

Merging `EffectGen`'s Iterator into `Effect` Prototype to Simplify `yield*` Syntax

I wonder why we don't merge EffectGen's iterator into
Effect
prototype, so that we don't need to wrap effects with the adapter while using yield* syntax?

Effect.gen(function* (_) {
  yield* _(Ef.log("Hello, world"));

  yield* _( // This pipe is non-sense, it's just for sake of an piping example.
    Ef.succeed("Hello, world"),
    Ef.tap(Ef.log),
    Ef.as(0)
  );
})
// becomes
Effect.gen(function* () {
  yield* Ef.log("Hello, world");

  yield* pipe(
    Ef.succeed("Hello, world"),
    Ef.tap(Ef.log),
    Ef.as(0)
  );
})
Was this page helpful?