<const T extends ReadonlyArray<Predicate.Any>>(elements: T): [
Extract<T[number], Refinement.Any>
] extends [never]
? Predicate<{ readonly [I in keyof T]: Predicate.In<T[I]> }>
: Refinement<
{
readonly [I in keyof T]: T[I] extends Refinement.Any
? Refinement.In<T[I]>
: Predicate.In<T[I]>
},
{
readonly [I in keyof T]: T[I] extends Refinement.Any
? Refinement.Out<T[I]>
: Predicate.In<T[I]>
}
>Creates a predicate for tuples by applying predicates to each element.
When to use
Use when you want to validate tuple positions independently by lifting element predicates into a tuple predicate.
Details
Returns a refinement if any element predicate is a refinement. Evaluation stops at the first failing element.
Example (Checking tuples)
import { Predicate } from "effect"
const tupleCheck = Predicate.Tuple([(n: number) => n > 0, Predicate.isString])
console.log(tupleCheck([1, "ok"]))export function function Tuple<
T extends ReadonlyArray<Predicate.Any>
>(
elements: T
): [Extract<T[number], Refinement.Any>] extends [
never
]
? Predicate<{
readonly [I in keyof T]: Predicate.In<T[I]>
}>
: Refinement<
{
readonly [I in keyof T]: T[I] extends Refinement.Any
? Refinement.In<T[I]>
: Predicate.In<T[I]>
},
{
readonly [I in keyof T]: T[I] extends Refinement.Any
? Refinement.Out<T[I]>
: Predicate.In<T[I]>
}
>
Creates a predicate for tuples by applying predicates to each element.
When to use
Use when you want to validate tuple positions independently by lifting
element predicates into a tuple predicate.
Details
Returns a refinement if any element predicate is a refinement. Evaluation
stops at the first failing element.
Example (Checking tuples)
import { Predicate } from "effect"
const tupleCheck = Predicate.Tuple([(n: number) => n > 0, Predicate.isString])
console.log(tupleCheck([1, "ok"]))
Tuple<const function (type parameter) T in Tuple<const T extends ReadonlyArray<Predicate.Any>>(elements: T): [Extract<T[number], Refinement.Any>] extends [never] ? Predicate<{ readonly [I in keyof T]: Predicate.In<T[I]>; }> : Refinement<{ readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.In<T[I]> : Predicate.In<T[I]>; }, { readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.Out<T[I]> : Predicate.In<T[I]>; }>T extends interface ReadonlyArray<T>ReadonlyArray<Predicate.type Predicate<in A>.Any = Predicate<any>A utility type representing any predicate type.
When to use
Use when you need a constraint for "any predicate" in generic code.
Details
This is type-only and creates no runtime value.
Example (Using generic constraints)
import { Predicate } from "effect"
type AnyPredicate = Predicate.Predicate.Any
Any>>(
elements: const T extends ReadonlyArray<Predicate.Any>elements: function (type parameter) T in Tuple<const T extends ReadonlyArray<Predicate.Any>>(elements: T): [Extract<T[number], Refinement.Any>] extends [never] ? Predicate<{ readonly [I in keyof T]: Predicate.In<T[I]>; }> : Refinement<{ readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.In<T[I]> : Predicate.In<T[I]>; }, { readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.Out<T[I]> : Predicate.In<T[I]>; }>T
): [type Extract<T, U> = T extends U
? T
: never
Extract from T those types that are assignable to U
Extract<function (type parameter) T in Tuple<const T extends ReadonlyArray<Predicate.Any>>(elements: T): [Extract<T[number], Refinement.Any>] extends [never] ? Predicate<{ readonly [I in keyof T]: Predicate.In<T[I]>; }> : Refinement<{ readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.In<T[I]> : Predicate.In<T[I]>; }, { readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.Out<T[I]> : Predicate.In<T[I]>; }>T[number], Refinement.type Refinement<in A, out B extends A>.Any = Refinement<any, any>A utility type representing any refinement type.
When to use
Use when you need a constraint for "any refinement" in generic code.
Details
This is type-only and creates no runtime value.
Example (Using generic constraints)
import { Predicate } from "effect"
type AnyRefinement = Predicate.Refinement.Any
Any>] extends [never] ? 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<{ readonly [function (type parameter) II in keyof function (type parameter) T in Tuple<const T extends ReadonlyArray<Predicate.Any>>(elements: T): [Extract<T[number], Refinement.Any>] extends [never] ? Predicate<{ readonly [I in keyof T]: Predicate.In<T[I]>; }> : Refinement<{ readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.In<T[I]> : Predicate.In<T[I]>; }, { readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.Out<T[I]> : Predicate.In<T[I]>; }>T]: Predicate.type Predicate<in A>.In<T extends Predicate.Any> = [T] extends [Predicate<infer _A>] ? _A : neverExtracts the input type A from a Predicate<A>.
When to use
Use when you want to infer the input type from a predicate type while
defining generic utilities over predicates.
Details
This is type-only and creates no runtime value. It resolves to never if
the type does not match Predicate.
Example (Inferring the input type)
import { Predicate } from "effect"
type P = Predicate.Predicate<number>
type Input = Predicate.Predicate.In<P>
In<function (type parameter) T in Tuple<const T extends ReadonlyArray<Predicate.Any>>(elements: T): [Extract<T[number], Refinement.Any>] extends [never] ? Predicate<{ readonly [I in keyof T]: Predicate.In<T[I]>; }> : Refinement<{ readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.In<T[I]> : Predicate.In<T[I]>; }, { readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.Out<T[I]> : Predicate.In<T[I]>; }>T[function (type parameter) II]> }>
: 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<
{ readonly [function (type parameter) II in keyof function (type parameter) T in Tuple<const T extends ReadonlyArray<Predicate.Any>>(elements: T): [Extract<T[number], Refinement.Any>] extends [never] ? Predicate<{ readonly [I in keyof T]: Predicate.In<T[I]>; }> : Refinement<{ readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.In<T[I]> : Predicate.In<T[I]>; }, { readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.Out<T[I]> : Predicate.In<T[I]>; }>T]: function (type parameter) T in Tuple<const T extends ReadonlyArray<Predicate.Any>>(elements: T): [Extract<T[number], Refinement.Any>] extends [never] ? Predicate<{ readonly [I in keyof T]: Predicate.In<T[I]>; }> : Refinement<{ readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.In<T[I]> : Predicate.In<T[I]>; }, { readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.Out<T[I]> : Predicate.In<T[I]>; }>T[function (type parameter) II] extends Refinement.type Refinement<in A, out B extends A>.Any = Refinement<any, any>A utility type representing any refinement type.
When to use
Use when you need a constraint for "any refinement" in generic code.
Details
This is type-only and creates no runtime value.
Example (Using generic constraints)
import { Predicate } from "effect"
type AnyRefinement = Predicate.Refinement.Any
Any ? Refinement.type Refinement<in A, out B extends A>.In<T extends Refinement.Any> = [T] extends [Refinement<infer _A, infer _ extends infer _A>] ? _A : neverExtracts the input type A from a Refinement<A, B>.
When to use
Use when you want to infer the input type from a refinement type.
Details
This is type-only and creates no runtime value. It resolves to never if
the type does not match Refinement.
Example (Inferring the input type)
import { Predicate } from "effect"
type R = Predicate.Refinement<unknown, string>
type Input = Predicate.Refinement.In<R>
In<function (type parameter) T in Tuple<const T extends ReadonlyArray<Predicate.Any>>(elements: T): [Extract<T[number], Refinement.Any>] extends [never] ? Predicate<{ readonly [I in keyof T]: Predicate.In<T[I]>; }> : Refinement<{ readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.In<T[I]> : Predicate.In<T[I]>; }, { readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.Out<T[I]> : Predicate.In<T[I]>; }>T[function (type parameter) II]> : Predicate.type Predicate<in A>.In<T extends Predicate.Any> = [T] extends [Predicate<infer _A>] ? _A : neverExtracts the input type A from a Predicate<A>.
When to use
Use when you want to infer the input type from a predicate type while
defining generic utilities over predicates.
Details
This is type-only and creates no runtime value. It resolves to never if
the type does not match Predicate.
Example (Inferring the input type)
import { Predicate } from "effect"
type P = Predicate.Predicate<number>
type Input = Predicate.Predicate.In<P>
In<function (type parameter) T in Tuple<const T extends ReadonlyArray<Predicate.Any>>(elements: T): [Extract<T[number], Refinement.Any>] extends [never] ? Predicate<{ readonly [I in keyof T]: Predicate.In<T[I]>; }> : Refinement<{ readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.In<T[I]> : Predicate.In<T[I]>; }, { readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.Out<T[I]> : Predicate.In<T[I]>; }>T[function (type parameter) II]> },
{ readonly [function (type parameter) II in keyof function (type parameter) T in Tuple<const T extends ReadonlyArray<Predicate.Any>>(elements: T): [Extract<T[number], Refinement.Any>] extends [never] ? Predicate<{ readonly [I in keyof T]: Predicate.In<T[I]>; }> : Refinement<{ readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.In<T[I]> : Predicate.In<T[I]>; }, { readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.Out<T[I]> : Predicate.In<T[I]>; }>T]: function (type parameter) T in Tuple<const T extends ReadonlyArray<Predicate.Any>>(elements: T): [Extract<T[number], Refinement.Any>] extends [never] ? Predicate<{ readonly [I in keyof T]: Predicate.In<T[I]>; }> : Refinement<{ readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.In<T[I]> : Predicate.In<T[I]>; }, { readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.Out<T[I]> : Predicate.In<T[I]>; }>T[function (type parameter) II] extends Refinement.type Refinement<in A, out B extends A>.Any = Refinement<any, any>A utility type representing any refinement type.
When to use
Use when you need a constraint for "any refinement" in generic code.
Details
This is type-only and creates no runtime value.
Example (Using generic constraints)
import { Predicate } from "effect"
type AnyRefinement = Predicate.Refinement.Any
Any ? Refinement.type Refinement<in A, out B extends A>.Out<T extends Refinement.Any> = [T] extends [Refinement<infer _, infer _B extends infer _>] ? _B : neverExtracts the output type B from a Refinement<A, B>.
When to use
Use when you want to infer the narrowed type from a refinement type.
Details
This is type-only and creates no runtime value. It resolves to never if
the type does not match Refinement.
Example (Inferring the output type)
import { Predicate } from "effect"
type R = Predicate.Refinement<unknown, string>
type Output = Predicate.Refinement.Out<R>
Out<function (type parameter) T in Tuple<const T extends ReadonlyArray<Predicate.Any>>(elements: T): [Extract<T[number], Refinement.Any>] extends [never] ? Predicate<{ readonly [I in keyof T]: Predicate.In<T[I]>; }> : Refinement<{ readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.In<T[I]> : Predicate.In<T[I]>; }, { readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.Out<T[I]> : Predicate.In<T[I]>; }>T[function (type parameter) II]> : Predicate.type Predicate<in A>.In<T extends Predicate.Any> = [T] extends [Predicate<infer _A>] ? _A : neverExtracts the input type A from a Predicate<A>.
When to use
Use when you want to infer the input type from a predicate type while
defining generic utilities over predicates.
Details
This is type-only and creates no runtime value. It resolves to never if
the type does not match Predicate.
Example (Inferring the input type)
import { Predicate } from "effect"
type P = Predicate.Predicate<number>
type Input = Predicate.Predicate.In<P>
In<function (type parameter) T in Tuple<const T extends ReadonlyArray<Predicate.Any>>(elements: T): [Extract<T[number], Refinement.Any>] extends [never] ? Predicate<{ readonly [I in keyof T]: Predicate.In<T[I]>; }> : Refinement<{ readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.In<T[I]> : Predicate.In<T[I]>; }, { readonly [I in keyof T]: T[I] extends Refinement.Any ? Refinement.Out<T[I]> : Predicate.In<T[I]>; }>T[function (type parameter) II]> }
>
{
return ((as: unknown[]as: interface Array<T>Array<unknown>) => {
for (let let i: numberi = 0; let i: numberi < elements: const T extends ReadonlyArray<Predicate.Any>elements.ReadonlyArray<T>.length: numberGets the length of the array. This is a number one higher than the highest element defined in an array.
length; let i: numberi++) {
if (elements: const T extends ReadonlyArray<Predicate.Any>elements[let i: numberi](as: unknown[]as[let i: numberi]) === false) {
return false
}
}
return true
}) as any
}