effect-io-ai

Package: effect
Module: Predicate

Predicate.Predicate

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))

See

Signature

export interface Predicate<in A> {
  (a: A): boolean
}

Source

Since v2.0.0