Effect CommunityEC
Effect Community3y ago
11 replies
attila

Simplifying the transformation from `Effect<never, never, Option<A>>` to `Effect<never, Error, A>`

What is a simpler way of going from Effect<never, never, Option<A>> to Effect<never, Error, A>?
declare const a: Option.Option<42>;

const res = pipe(
  Effect.succeed(a),
  Effect.filterOrFail(
    Option.isSome,
    () => new Error("Boom"),
  ),
  Effect.map(({ value }) => value)
);
Was this page helpful?