Hyperlinkv0.8.0-beta.28

Predicate

Predicate.nandconsteffect/Predicate.ts:1790
<A>(that: Predicate<A>): (self: Predicate<A>) => Predicate<A>
<A>(self: Predicate<A>, that: Predicate<A>): Predicate<A>

Creates a predicate that returns true unless both predicates are true.

When to use

Use when you want to combine two Predicates with logical NAND semantics.

Details

Returns the negation of and.

Example (Checking NAND conditions)

import { Predicate } from "effect"

const notBoth = Predicate.nand(Predicate.isString, Predicate.isNumber)

console.log(notBoth("a"))
combinatorsandnot
export const nand: {
  <A>(that: Predicate<A>): (self: Predicate<A>) => Predicate<A>
  <A>(self: Predicate<A>, that: Predicate<A>): Predicate<A>
} = dual(
  2,
  <A>(self: Predicate<A>, that: Predicate<A>): Predicate<A> => (a) => !(self(a) && that(a))
)