<A, B extends A>(refinement: Refinement<NoInfer<A>, B>): (
self: Option<A>
) => self is Option<B>
<A>(predicate: Predicate<NoInfer<A>>): (self: Option<A>) => boolean
<A, B extends A>(
self: Option<A>,
refinement: Refinement<A, B>
): self is Option<B>
<A>(self: Option<A>, predicate: Predicate<A>): booleanChecks whether the value in a Some satisfies a predicate or refinement.
When to use
Use to check a condition on an optional value without unwrapping
Details
None→falseSomewherepredicate(value)istrue→trueSomewherepredicate(value)isfalse→false- With a refinement, narrows the
Optiontype ontrue
Example (Testing a condition)
import { Option } from "effect"
const isEven = (n: number) => n % 2 === 0
console.log(Option.some(2).pipe(Option.exists(isEven)))
// Output: true
console.log(Option.some(1).pipe(Option.exists(isEven)))
// Output: false
console.log(Option.none().pipe(Option.exists(isEven)))
// Output: falseexport const const exists: {
<A, B extends A>(
refinement: Refinement<NoInfer<A>, B>
): (self: Option<A>) => self is Option<B>
<A>(predicate: Predicate<NoInfer<A>>): (
self: Option<A>
) => boolean
<A, B extends A>(
self: Option<A>,
refinement: Refinement<A, B>
): self is Option<B>
<A>(
self: Option<A>,
predicate: Predicate<A>
): boolean
}
Checks whether the value in a Some satisfies a predicate or refinement.
When to use
Use to check a condition on an optional value without unwrapping
Details
None → false
Some where predicate(value) is true → true
Some where predicate(value) is false → false
- With a refinement, narrows the
Option type on true
Example (Testing a condition)
import { Option } from "effect"
const isEven = (n: number) => n % 2 === 0
console.log(Option.some(2).pipe(Option.exists(isEven)))
// Output: true
console.log(Option.some(1).pipe(Option.exists(isEven)))
// Output: false
console.log(Option.none().pipe(Option.exists(isEven)))
// Output: false
exists: {
<function (type parameter) A in <A, B extends A>(refinement: Refinement<NoInfer<A>, B>): (self: Option<A>) => self is Option<B>A, function (type parameter) B in <A, B extends A>(refinement: Refinement<NoInfer<A>, B>): (self: Option<A>) => self is Option<B>B extends function (type parameter) A in <A, B extends A>(refinement: Refinement<NoInfer<A>, B>): (self: Option<A>) => self is Option<B>A>(refinement: Refinement<NoInfer<A>, B>refinement: interface Refinement<in A, out B extends A>A predicate that also narrows the input type when it returns true.
When to use
Use when you want a runtime check that refines A to B for TypeScript,
especially when composing type guards with
compose
or safely
checking unknown values.
Details
A refinement returns a type predicate (a is B). Use it with if or
filter to narrow types.
Example (Narrowing unknown values)
import { Predicate } from "effect"
const isString: Predicate.Refinement<unknown, string> = (u): u is string => typeof u === "string"
const data: unknown = "hello"
if (isString(data)) {
console.log(data.toUpperCase())
}
Type-level utilities for working with
Refinement
types.
When to use
Use when you need to extract input and output types from refinement
signatures while writing generic helpers over refinements.
Details
These utilities are type-only, create no runtime values, and the namespace is
erased at runtime.
Example (Extracting refinement types)
import { Predicate } from "effect"
type IsString = Predicate.Refinement<unknown, string>
type Input = Predicate.Refinement.In<IsString>
type Output = Predicate.Refinement.Out<IsString>
Refinement<type NoInfer<A> = [A][A extends any ? 0 : never]Prevents TypeScript from inferring a type parameter from a specific
position.
When to use
Use when a function parameter must match an inferred type without becoming
an inference source.
Details
The parameter using NoInfer must still match the inferred type.
Example (Controlling inference)
import type { Types } from "effect"
declare function withDefault<T>(value: T, fallback: Types.NoInfer<T>): T
// T is inferred as "a" | "b" from the first argument only
const result = withDefault<"a" | "b">("a", "b")
NoInfer<function (type parameter) A in <A, B extends A>(refinement: Refinement<NoInfer<A>, B>): (self: Option<A>) => self is Option<B>A>, function (type parameter) B in <A, B extends A>(refinement: Refinement<NoInfer<A>, B>): (self: Option<A>) => self is Option<B>B>): (self: Option<A>self: type Option<A> = None<A> | Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<function (type parameter) A in <A, B extends A>(refinement: Refinement<NoInfer<A>, B>): (self: Option<A>) => self is Option<B>A>) => self: Option<A>self is type Option<A> = None<A> | Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<function (type parameter) B in <A, B extends A>(refinement: Refinement<NoInfer<A>, B>): (self: Option<A>) => self is Option<B>B>
<function (type parameter) A in <A>(predicate: Predicate<NoInfer<A>>): (self: Option<A>) => booleanA>(predicate: Predicate<NoInfer<A>>predicate: interface Predicate<in A>A function that decides whether a value of type A satisfies a condition.
When to use
Use when you want a reusable boolean check for A, especially when you plan
to combine checks with
and
/
or
or pass a predicate to arrays
and iterables.
Details
A predicate returns true or false and never throws by itself. It does not
narrow types unless you use Refinement.
Example (Defining a predicate)
import { Predicate } from "effect"
const isPositive: Predicate.Predicate<number> = (n) => n > 0
console.log(isPositive(1))
Type-level utilities for working with
Predicate
types.
When to use
Use when you need to extract input types from predicate signatures while
writing generic helpers over predicate types.
Details
These utilities are type-only, create no runtime values, and the namespace is
erased at runtime.
Example (Extracting predicate input)
import { Predicate } from "effect"
type IsString = Predicate.Predicate<string>
type Input = Predicate.Predicate.In<IsString>
Predicate<type NoInfer<A> = [A][A extends any ? 0 : never]Prevents TypeScript from inferring a type parameter from a specific
position.
When to use
Use when a function parameter must match an inferred type without becoming
an inference source.
Details
The parameter using NoInfer must still match the inferred type.
Example (Controlling inference)
import type { Types } from "effect"
declare function withDefault<T>(value: T, fallback: Types.NoInfer<T>): T
// T is inferred as "a" | "b" from the first argument only
const result = withDefault<"a" | "b">("a", "b")
NoInfer<function (type parameter) A in <A>(predicate: Predicate<NoInfer<A>>): (self: Option<A>) => booleanA>>): (self: Option<A>self: type Option<A> = None<A> | Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<function (type parameter) A in <A>(predicate: Predicate<NoInfer<A>>): (self: Option<A>) => booleanA>) => boolean
<function (type parameter) A in <A, B extends A>(self: Option<A>, refinement: Refinement<A, B>): self is Option<B>A, function (type parameter) B in <A, B extends A>(self: Option<A>, refinement: Refinement<A, B>): self is Option<B>B extends function (type parameter) A in <A, B extends A>(self: Option<A>, refinement: Refinement<A, B>): self is Option<B>A>(self: Option<A>self: type Option<A> = None<A> | Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<function (type parameter) A in <A, B extends A>(self: Option<A>, refinement: Refinement<A, B>): self is Option<B>A>, refinement: Refinement<A, B>refinement: interface Refinement<in A, out B extends A>A predicate that also narrows the input type when it returns true.
When to use
Use when you want a runtime check that refines A to B for TypeScript,
especially when composing type guards with
compose
or safely
checking unknown values.
Details
A refinement returns a type predicate (a is B). Use it with if or
filter to narrow types.
Example (Narrowing unknown values)
import { Predicate } from "effect"
const isString: Predicate.Refinement<unknown, string> = (u): u is string => typeof u === "string"
const data: unknown = "hello"
if (isString(data)) {
console.log(data.toUpperCase())
}
Type-level utilities for working with
Refinement
types.
When to use
Use when you need to extract input and output types from refinement
signatures while writing generic helpers over refinements.
Details
These utilities are type-only, create no runtime values, and the namespace is
erased at runtime.
Example (Extracting refinement types)
import { Predicate } from "effect"
type IsString = Predicate.Refinement<unknown, string>
type Input = Predicate.Refinement.In<IsString>
type Output = Predicate.Refinement.Out<IsString>
Refinement<function (type parameter) A in <A, B extends A>(self: Option<A>, refinement: Refinement<A, B>): self is Option<B>A, function (type parameter) B in <A, B extends A>(self: Option<A>, refinement: Refinement<A, B>): self is Option<B>B>): self: Option<A>self is type Option<A> = None<A> | Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<function (type parameter) B in <A, B extends A>(self: Option<A>, refinement: Refinement<A, B>): self is Option<B>B>
<function (type parameter) A in <A>(self: Option<A>, predicate: Predicate<A>): booleanA>(self: Option<A>self: type Option<A> = None<A> | Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<function (type parameter) A in <A>(self: Option<A>, predicate: Predicate<A>): booleanA>, predicate: Predicate<A>predicate: interface Predicate<in A>A function that decides whether a value of type A satisfies a condition.
When to use
Use when you want a reusable boolean check for A, especially when you plan
to combine checks with
and
/
or
or pass a predicate to arrays
and iterables.
Details
A predicate returns true or false and never throws by itself. It does not
narrow types unless you use Refinement.
Example (Defining a predicate)
import { Predicate } from "effect"
const isPositive: Predicate.Predicate<number> = (n) => n > 0
console.log(isPositive(1))
Type-level utilities for working with
Predicate
types.
When to use
Use when you need to extract input types from predicate signatures while
writing generic helpers over predicate types.
Details
These utilities are type-only, create no runtime values, and the namespace is
erased at runtime.
Example (Extracting predicate input)
import { Predicate } from "effect"
type IsString = Predicate.Predicate<string>
type Input = Predicate.Predicate.In<IsString>
Predicate<function (type parameter) A in <A>(self: Option<A>, predicate: Predicate<A>): booleanA>): boolean
} = import dualdual(
2,
<function (type parameter) A in <A, B extends A>(self: Option<A>, refinement: Refinement<A, B>): self is Option<B>A, function (type parameter) B in <A, B extends A>(self: Option<A>, refinement: Refinement<A, B>): self is Option<B>B extends function (type parameter) A in <A, B extends A>(self: Option<A>, refinement: Refinement<A, B>): self is Option<B>A>(self: Option<A>self: type Option<A> = None<A> | Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<function (type parameter) A in <A, B extends A>(self: Option<A>, refinement: Refinement<A, B>): self is Option<B>A>, refinement: Refinement<A, B>refinement: interface Refinement<in A, out B extends A>A predicate that also narrows the input type when it returns true.
When to use
Use when you want a runtime check that refines A to B for TypeScript,
especially when composing type guards with
compose
or safely
checking unknown values.
Details
A refinement returns a type predicate (a is B). Use it with if or
filter to narrow types.
Example (Narrowing unknown values)
import { Predicate } from "effect"
const isString: Predicate.Refinement<unknown, string> = (u): u is string => typeof u === "string"
const data: unknown = "hello"
if (isString(data)) {
console.log(data.toUpperCase())
}
Type-level utilities for working with
Refinement
types.
When to use
Use when you need to extract input and output types from refinement
signatures while writing generic helpers over refinements.
Details
These utilities are type-only, create no runtime values, and the namespace is
erased at runtime.
Example (Extracting refinement types)
import { Predicate } from "effect"
type IsString = Predicate.Refinement<unknown, string>
type Input = Predicate.Refinement.In<IsString>
type Output = Predicate.Refinement.Out<IsString>
Refinement<function (type parameter) A in <A, B extends A>(self: Option<A>, refinement: Refinement<A, B>): self is Option<B>A, function (type parameter) B in <A, B extends A>(self: Option<A>, refinement: Refinement<A, B>): self is Option<B>B>): self: Option<A>self is type Option<A> = None<A> | Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<function (type parameter) B in <A, B extends A>(self: Option<A>, refinement: Refinement<A, B>): self is Option<B>B> =>
const isNone: <A>(
self: Option<A>
) => self is None<A>
Checks whether an Option is None (absent).
When to use
Use when you need to branch on an absent Option before accessing .value.
Details
- Acts as a type guard, narrowing to
None<A>
Example (Checking for None)
import { Option } from "effect"
console.log(Option.isNone(Option.some(1)))
// Output: false
console.log(Option.isNone(Option.none()))
// Output: true
isNone(self: Option<A>self) ? false : refinement: Refinement<A, B>refinement(self: Option<A>(parameter) self: {
_tag: "Some";
_op: "Some";
value: A;
valueOrUndefined: A;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self.Some<A>.value: Avalue)
)