<A>(collection: Iterable<Predicate<A>>): Predicate<A>Creates a predicate that returns true if any predicate in the collection returns true.
When to use
Use when you have a dynamic list of predicates and only need one to pass.
Details
Evaluation short-circuits on the first true. The collection is iterated
each time the predicate is called.
Example (Checking any predicate)
import { Predicate } from "effect"
const anyCheck = Predicate.some([Predicate.isString, Predicate.isNumber])
console.log(anyCheck("ok"))export function function some<A>(
collection: Iterable<Predicate<A>>
): Predicate<A>
Creates a predicate that returns true if any predicate in the collection returns true.
When to use
Use when you have a dynamic list of predicates and only need one to pass.
Details
Evaluation short-circuits on the first true. The collection is iterated
each time the predicate is called.
Example (Checking any predicate)
import { Predicate } from "effect"
const anyCheck = Predicate.some([Predicate.isString, Predicate.isNumber])
console.log(anyCheck("ok"))
some<function (type parameter) A in some<A>(collection: Iterable<Predicate<A>>): Predicate<A>A>(collection: Iterable<Predicate<A>>collection: interface Iterable<T, TReturn = any, TNext = any>Iterable<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 some<A>(collection: Iterable<Predicate<A>>): Predicate<A>A>>): 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 some<A>(collection: Iterable<Predicate<A>>): Predicate<A>A> {
return (a: Aa) => {
for (const const p: Predicate<A>p of collection: Iterable<Predicate<A>>collection) {
if (const p: Predicate<A>p(a: Aa)) {
return true
}
}
return false
}
}