Hyperlinkv0.8.0-beta.28

Effect

Effect.asconsteffect/Effect.ts:2392
<B>(value: B): <A, E, R>(self: Effect<A, E, R>) => Effect<B, E, R>
<A, E, R, B>(self: Effect<A, E, R>, value: B): Effect<B, E, R>

Replaces the value inside an effect with a constant value.

When to use

Use to replace a successful value with a constant while preserving failures and requirements.

Details

as allows you to ignore the original value inside an effect and replace it with a new constant value.

Example (Replacing a success value)

import { Effect, pipe } from "effect"

// Replaces the value 5 with the constant "new value"
const program = pipe(Effect.succeed(5), Effect.as("new value"))

Effect.runPromise(program).then(console.log)
// Output: "new value"
mappingmapasVoid
Source effect/Effect.ts:23924 lines
export const as: {
  <B>(value: B): <A, E, R>(self: Effect<A, E, R>) => Effect<B, E, R>
  <A, E, R, B>(self: Effect<A, E, R>, value: B): Effect<B, E, R>
} = internal.as
Referenced by 13 symbols