Hyperlinkv0.8.0-beta.28

Result

Result.Doconsteffect/Result.ts:1616
Result<{}, never>

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 }, ... }
do notationbindlet_genbindTo
Source effect/Result.ts:16161 lines
export const Do: Result<{}> = succeed({})