Hyperlinkv0.8.0-beta.28

Effect

Effect.fromNullishOrconsteffect/Effect.ts:1886
<A>(value: A): Effect<NonNullable<A>, Cause.NoSuchElementError>

Converts a nullable value to an Effect, failing with a NoSuchElementError when the value is null or undefined.

Example (Failing on nullish values)

import { Console, Effect } from "effect"

const program = Effect.fn(function*(input: string | null) {
  const value = yield* Effect.fromNullishOr(input)
  yield* Console.log(value)
},
  Effect.catch(() => Console.log("missing"))
)

Effect.runPromise(program(null))
// Output: missing
Effect.runPromise(program("hello"))
// Output: hello
converting
Source effect/Effect.ts:18861 lines
export const fromNullishOr: <A>(value: A) => Effect<NonNullable<A>, Cause.NoSuchElementError> = internal.fromNullishOr