Hyperlinkv0.8.0-beta.28

Result

Result.bindToconsteffect/Result.ts:1700
<N extends string>(name: N): <R, L>(
  self: Result<R, L>
) => Result<Record<N, R>, L>
<R, L, N extends string>(self: Result<R, L>, name: N): Result<
  Record<N, R>,
  L
>

Wraps the success value of a Result into a named field, producing a Result<Record<N, A>>.

When to use

Use to name the success value of an existing Result before continuing a do-notation pipeline.

Details

This is typically used to start a do-notation chain from an existing Result.

Example (Wrapping a value into a named field)

import { pipe, Result } from "effect"

const result = pipe(
  Result.succeed(42),
  Result.bindTo("answer")
)
console.log(result)
// Output: { _tag: "Success", success: { answer: 42 }, ... }
do notationDobind
Source effect/Result.ts:17004 lines
export const bindTo: {
  <N extends string>(name: N): <R, L>(self: Result<R, L>) => Result<Record<N, R>, L>
  <R, L, N extends string>(self: Result<R, L>, name: N): Result<Record<N, R>, L>
} = doNotation.bindTo<ResultTypeLambda>(map)