Package: effect
Module: Result
Transforms the success channel of a Result, leaving the failure channel unchanged.
When to use
Use to apply a transformation to the success value of a Result while
preserving any existing failure.
Details
Success, applies f to the value and returns a new SuccessFailure, returns it as-isflatMap if f returns a Result (to avoid nested Results)Example (Doubling the success value)
import { pipe, Result } from "effect"
const result = pipe(
Result.succeed(3),
Result.map((n) => n * 2)
)
console.log(result)
// Output: { _tag: "Success", success: 6, ... }
See
mapError to transform only the error valuemapBoth to transform both channelsflatMap when f returns a ResultSignature
declare const map: { <A, A2>(f: (ok: A) => A2): <E>(self: Result<A, E>) => Result<A2, E>; <A, E, A2>(self: Result<A, E>, f: (ok: A) => A2): Result<A2, E>; }
Since v2.0.0