Hyperlinkv0.8.0-beta.28

Predicate

Predicate.notfunctioneffect/Predicate.ts:1545
<A>(self: Predicate<A>): Predicate<A>

Negates a predicate.

When to use

Use when you want the inverse of an existing predicate.

Details

Returns a new predicate that flips the boolean result.

Example (Negating a predicate)

import { Predicate } from "effect"

const isNotString = Predicate.not(Predicate.isString)

console.log(isNotString(1))
combinatorsandorxor
export function not<A>(self: Predicate<A>): Predicate<A> {
  return (a) => !self(a)
}