Package: effect
Module: Effect
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
Signature
declare const fromNullishOr: <A>(value: A) => Effect<NonNullable<A>, Cause.NoSuchElementError>
Since v4.0.0