Hyperlinkv0.8.0-beta.28

SchemaGetter

SchemaGetter.succeedfunctioneffect/SchemaGetter.ts:121
<const T, E>(t: T): Getter<T, E>

Creates a getter that always produces the given constant value, ignoring the input.

When to use

Use when you need a schema getter that always decodes a field to a fixed value.

Details

The getter is pure and always returns Option.some(t) regardless of whether the input is Some or None.

Example (Returning a constant getter)

import { SchemaGetter } from "effect"

const alwaysZero = SchemaGetter.succeed(0)
// alwaysZero: Getter<0, unknown> — always produces 0
export function succeed<const T, E>(t: T): Getter<T, E> {
  return new Getter(() => Effect.succeedSome(t))
}