Effect CommunityEC
Effect Community8mo ago
2 replies
adama

Map Exit<A,E> to Effect<A,E>

How do I map an Exit to an Effect?

I'm currently using this pattern, which seems to work:

const program: Effect<'hello', never, never> = Effect.gen(function* () {
  const exit = yield* Effect.exit(Effect.succeed('hello'))
  const effect = yield* Exit.isSuccess(exit)
    ? Effect.succeed("ok" as const)
    : Effect.failCause(exit.cause);
  return effect;
})


Though I was curious if there's any more declarative way – I was expecting something like Effect.fromExit (though it doesn't quite make sense since the exit is already an effect subtype)

Interestingly, almost every LLM suggests there is some Effect.done(exit) utility, but I'm not finding any information about this.

Thanks!
Was this page helpful?