effect-io-ai

Package: effect
Module: Result

Result.Do

Provides the starting point for the “do notation” simulation with Result.

When to use

Use to start a Result do-notation pipeline from an empty successful record before adding named fields from Result-producing computations and pure computed values.

Details

Creates a Result<{}> (success with an empty object). Use with bind to add Result-producing fields and let to add pure computed fields.

Example (Building an object step by step)

import { pipe, Result } from "effect"

const result = pipe(
  Result.Do,
  Result.bind("x", () => Result.succeed(2)),
  Result.bind("y", () => Result.succeed(3)),
  Result.let("sum", ({ x, y }) => x + y)
)
console.log(result)
// Output: { _tag: "Success", success: { x: 2, y: 3, sum: 5 }, ... }

See

Signature

declare const Do: Result<{}, never>

Source

Since v2.0.0