Handling Effect-Wrapped Results in Typescript

Hi all, I discovered the effect library earlier today and while going through the docs I am a bit confused with a very basic question, how to use a effect wrapped result?

With one of the first examples:
const divide = (
  a: number,
  b: number
): Effect.Effect<number, Error, never> =>
  b === 0
    ? Effect.fail(new Error("Cannot divide by zero"))
    : Effect.succeed(a / b);


how would I write the equivalent of

try {
  const result = divideWithoutEffect(5,0)
  console.log(`result: ${result}`
} catch (e) {
  console.error(`something bad happened: ${e.message}`)
}
Was this page helpful?