/**
* Works with TypeScript `boolean` values.
*
* This module exposes the native `Boolean` constructor together with helpers
* for checking values, choosing between lazy branches, combining booleans with
* logical operations, checking collections with `every` or `some`, ordering
* booleans, and reducing boolean values.
*
* @stability stable
* @since 2.0.0
*/
import * as Equ from "./Equivalence.ts";
import type { LazyArg } from "./Function.ts";
import * as order from "./Order.ts";
import * as Reducer from "./Reducer.ts";
/**
* Exposes the global boolean constructor for JavaScript truthiness
* coercion.
*
* **When to use**
*
* Use to access native JavaScript truthiness coercion from the Effect module
* namespace.
*
* **Gotchas**
*
* This follows native truthiness rules. For example, non-empty strings such as
* `"false"` coerce to `true`.
*
* **Example** (Coercing values to booleans)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.Boolean(1) // => true
* Boolean.Boolean("false") // => true
* Boolean.Boolean(0) // => false
* ```
*
* @stability stable
* @category constructors
* @since 4.0.0
*/
export declare const Boolean: BooleanConstructor;
/**
* Checks whether a value is a `boolean`.
*
* **When to use**
*
* Use to validate unknown input and narrow it to `boolean`.
*
* **Example** (Checking for booleans)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.isBoolean(true) // => true
* Boolean.isBoolean("true") // => false
* ```
*
* @stability stable
* @category guards
* @since 2.0.0
*/
export declare const isBoolean: (input: unknown) => input is boolean;
/**
* Chooses between two lazy branches based on a boolean value.
*
* **When to use**
*
* Use to choose between two lazy branches based on a boolean value.
*
* **Example** (Pattern matching on booleans)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.match(true, {
* onFalse: () => "It's false!",
* onTrue: () => "It's true!"
* }) // => "It's true!"
* ```
*
* @stability stable
* @category pattern matching
* @since 2.0.0
*/
export declare const match: {
/**
* Chooses between two lazy branches based on a boolean value.
*
* **When to use**
*
* Use to choose between two lazy branches based on a boolean value.
*
* **Example** (Pattern matching on booleans)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.match(true, {
* onFalse: () => "It's false!",
* onTrue: () => "It's true!"
* }) // => "It's true!"
* ```
*
* @stability stable
* @category pattern matching
* @since 2.0.0
*/
(options: {
readonly onFalse: LazyArg;
readonly onTrue: LazyArg;
}): (value: boolean) => A | B;
/**
* Chooses between two lazy branches based on a boolean value.
*
* **When to use**
*
* Use to choose between two lazy branches based on a boolean value.
*
* **Example** (Pattern matching on booleans)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.match(true, {
* onFalse: () => "It's false!",
* onTrue: () => "It's true!"
* }) // => "It's true!"
* ```
*
* @stability stable
* @category pattern matching
* @since 2.0.0
*/
(value: boolean, options: {
readonly onFalse: LazyArg;
readonly onTrue: LazyArg;
}): A | B;
};
/**
* Provides an `Order` instance for `boolean` that allows comparing and sorting boolean values.
* In this ordering, `false` is considered less than `true`.
*
* **When to use**
*
* Use when you need to sort or compare boolean values through APIs that accept
* an ordering instance where `false` comes before `true`.
*
* **Example** (Comparing booleans)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.Order(false, true) // => -1
* Boolean.Order(true, false) // => 1
* Boolean.Order(true, true) // => 0
* ```
*
* @stability stable
* @category instances
* @since 2.0.0
*/
export declare const Order: order.Order;
/**
* Equivalence instance for booleans using strict equality (`===`).
*
* **When to use**
*
* Use when checking boolean equality through APIs that accept an equivalence
* relation.
*
* **Example** (Comparing booleans for equivalence)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.Equivalence(true, true) // => true
* Boolean.Equivalence(true, false) // => false
* ```
*
* @stability stable
* @category instances
* @since 2.0.0
*/
export declare const Equivalence: Equ.Equivalence;
/**
* Negates the given boolean: `!self`
*
* **When to use**
*
* Use to invert a boolean value.
*
* **Example** (Negating booleans)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.not(true) // => false
* Boolean.not(false) // => true
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
export declare const not: (self: boolean) => boolean;
/**
* Combines two booleans using logical AND: `self && that`.
*
* **When to use**
*
* Use to require both boolean operands to be `true`.
*
* **Details**
*
* Supports both data-first and data-last forms.
*
* **Example** (Combining booleans with AND)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.and(true, true) // => true
* Boolean.and(true, false) // => false
* Boolean.and(false, true) // => false
* Boolean.and(false, false) // => false
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
export declare const and: {
/**
* Combines two booleans using logical AND: `self && that`.
*
* **When to use**
*
* Use to require both boolean operands to be `true`.
*
* **Details**
*
* Supports both data-first and data-last forms.
*
* **Example** (Combining booleans with AND)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.and(true, true) // => true
* Boolean.and(true, false) // => false
* Boolean.and(false, true) // => false
* Boolean.and(false, false) // => false
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
(that: boolean): (self: boolean) => boolean;
/**
* Combines two booleans using logical AND: `self && that`.
*
* **When to use**
*
* Use to require both boolean operands to be `true`.
*
* **Details**
*
* Supports both data-first and data-last forms.
*
* **Example** (Combining booleans with AND)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.and(true, true) // => true
* Boolean.and(true, false) // => false
* Boolean.and(false, true) // => false
* Boolean.and(false, false) // => false
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
(self: boolean, that: boolean): boolean;
};
/**
* Combines two booleans using NAND: `!(self && that)`.
*
* **When to use**
*
* Use to negate a logical AND result.
*
* **Example** (Combining booleans with NAND)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.nand(true, true) // => false
* Boolean.nand(true, false) // => true
* Boolean.nand(false, true) // => true
* Boolean.nand(false, false) // => true
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
export declare const nand: {
/**
* Combines two booleans using NAND: `!(self && that)`.
*
* **When to use**
*
* Use to negate a logical AND result.
*
* **Example** (Combining booleans with NAND)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.nand(true, true) // => false
* Boolean.nand(true, false) // => true
* Boolean.nand(false, true) // => true
* Boolean.nand(false, false) // => true
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
(that: boolean): (self: boolean) => boolean;
/**
* Combines two booleans using NAND: `!(self && that)`.
*
* **When to use**
*
* Use to negate a logical AND result.
*
* **Example** (Combining booleans with NAND)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.nand(true, true) // => false
* Boolean.nand(true, false) // => true
* Boolean.nand(false, true) // => true
* Boolean.nand(false, false) // => true
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
(self: boolean, that: boolean): boolean;
};
/**
* Combines two booleans using OR: `self || that`.
*
* **When to use**
*
* Use to accept when either boolean operand is `true`.
*
* **Example** (Combining booleans with OR)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.or(true, true) // => true
* Boolean.or(true, false) // => true
* Boolean.or(false, true) // => true
* Boolean.or(false, false) // => false
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
export declare const or: {
/**
* Combines two booleans using OR: `self || that`.
*
* **When to use**
*
* Use to accept when either boolean operand is `true`.
*
* **Example** (Combining booleans with OR)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.or(true, true) // => true
* Boolean.or(true, false) // => true
* Boolean.or(false, true) // => true
* Boolean.or(false, false) // => false
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
(that: boolean): (self: boolean) => boolean;
/**
* Combines two booleans using OR: `self || that`.
*
* **When to use**
*
* Use to accept when either boolean operand is `true`.
*
* **Example** (Combining booleans with OR)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.or(true, true) // => true
* Boolean.or(true, false) // => true
* Boolean.or(false, true) // => true
* Boolean.or(false, false) // => false
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
(self: boolean, that: boolean): boolean;
};
/**
* Combines two booleans using NOR: `!(self || that)`.
*
* **When to use**
*
* Use to accept only when both boolean operands are `false`.
*
* **Example** (Combining booleans with NOR)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.nor(true, true) // => false
* Boolean.nor(true, false) // => false
* Boolean.nor(false, true) // => false
* Boolean.nor(false, false) // => true
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
export declare const nor: {
/**
* Combines two booleans using NOR: `!(self || that)`.
*
* **When to use**
*
* Use to accept only when both boolean operands are `false`.
*
* **Example** (Combining booleans with NOR)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.nor(true, true) // => false
* Boolean.nor(true, false) // => false
* Boolean.nor(false, true) // => false
* Boolean.nor(false, false) // => true
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
(that: boolean): (self: boolean) => boolean;
/**
* Combines two booleans using NOR: `!(self || that)`.
*
* **When to use**
*
* Use to accept only when both boolean operands are `false`.
*
* **Example** (Combining booleans with NOR)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.nor(true, true) // => false
* Boolean.nor(true, false) // => false
* Boolean.nor(false, true) // => false
* Boolean.nor(false, false) // => true
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
(self: boolean, that: boolean): boolean;
};
/**
* Combines two booleans using XOR: `(!self && that) || (self && !that)`.
*
* **When to use**
*
* Use to accept when exactly one boolean operand is `true`.
*
* **Example** (Combining booleans with XOR)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.xor(true, true) // => false
* Boolean.xor(true, false) // => true
* Boolean.xor(false, true) // => true
* Boolean.xor(false, false) // => false
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
export declare const xor: {
/**
* Combines two booleans using XOR: `(!self && that) || (self && !that)`.
*
* **When to use**
*
* Use to accept when exactly one boolean operand is `true`.
*
* **Example** (Combining booleans with XOR)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.xor(true, true) // => false
* Boolean.xor(true, false) // => true
* Boolean.xor(false, true) // => true
* Boolean.xor(false, false) // => false
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
(that: boolean): (self: boolean) => boolean;
/**
* Combines two booleans using XOR: `(!self && that) || (self && !that)`.
*
* **When to use**
*
* Use to accept when exactly one boolean operand is `true`.
*
* **Example** (Combining booleans with XOR)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.xor(true, true) // => false
* Boolean.xor(true, false) // => true
* Boolean.xor(false, true) // => true
* Boolean.xor(false, false) // => false
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
(self: boolean, that: boolean): boolean;
};
/**
* Combines two booleans using EQV (aka XNOR): `!xor(self, that)`.
*
* **When to use**
*
* Use to accept when both boolean operands have the same truth value.
*
* **Example** (Checking boolean equivalence)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.eqv(true, true) // => true
* Boolean.eqv(true, false) // => false
* Boolean.eqv(false, true) // => false
* Boolean.eqv(false, false) // => true
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
export declare const eqv: {
/**
* Combines two booleans using EQV (aka XNOR): `!xor(self, that)`.
*
* **When to use**
*
* Use to accept when both boolean operands have the same truth value.
*
* **Example** (Checking boolean equivalence)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.eqv(true, true) // => true
* Boolean.eqv(true, false) // => false
* Boolean.eqv(false, true) // => false
* Boolean.eqv(false, false) // => true
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
(that: boolean): (self: boolean) => boolean;
/**
* Combines two booleans using EQV (aka XNOR): `!xor(self, that)`.
*
* **When to use**
*
* Use to accept when both boolean operands have the same truth value.
*
* **Example** (Checking boolean equivalence)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.eqv(true, true) // => true
* Boolean.eqv(true, false) // => false
* Boolean.eqv(false, true) // => false
* Boolean.eqv(false, false) // => true
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
(self: boolean, that: boolean): boolean;
};
/**
* Combines two booleans using an implication: `(!self || that)`.
*
* **When to use**
*
* Use to model logical implication between a condition and a consequence.
*
* **Example** (Checking boolean implication)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.implies(true, true) // => true
* Boolean.implies(true, false) // => false
* Boolean.implies(false, true) // => true
* Boolean.implies(false, false) // => true
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
export declare const implies: {
/**
* Combines two booleans using an implication: `(!self || that)`.
*
* **When to use**
*
* Use to model logical implication between a condition and a consequence.
*
* **Example** (Checking boolean implication)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.implies(true, true) // => true
* Boolean.implies(true, false) // => false
* Boolean.implies(false, true) // => true
* Boolean.implies(false, false) // => true
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
(that: boolean): (self: boolean) => boolean;
/**
* Combines two booleans using an implication: `(!self || that)`.
*
* **When to use**
*
* Use to model logical implication between a condition and a consequence.
*
* **Example** (Checking boolean implication)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.implies(true, true) // => true
* Boolean.implies(true, false) // => false
* Boolean.implies(false, true) // => true
* Boolean.implies(false, false) // => true
* ```
*
* @stability stable
* @category combinators
* @since 2.0.0
*/
(self: boolean, that: boolean): boolean;
};
/**
* Checks whether every boolean in a collection is `true`.
*
* **When to use**
*
* Use to check that every boolean in an iterable is `true`.
*
* **Example** (Checking every boolean)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.every([true, true, true]) // => true
* Boolean.every([true, false, true]) // => false
* ```
*
* @see {@link some} for checking whether at least one value is `true`
* @see {@link ReducerAnd} for reducing booleans with AND through a `Reducer`
*
* @stability stable
* @category predicates
* @since 2.0.0
*/
export declare const every: (collection: Iterable) => boolean;
/**
* Checks whether at least one boolean in a collection is `true`.
*
* **When to use**
*
* Use to check that at least one boolean in an iterable is `true`.
*
* **Example** (Checking some booleans)
*
* ```ts import.meta.vitest
* import { Boolean } from "effect"
*
* Boolean.some([true, false, true]) // => true
* Boolean.some([false, false, false]) // => false
* ```
*
* @see {@link every} for checking whether all values are `true`
* @see {@link ReducerOr} for reducing booleans with OR through a `Reducer`
*
* @stability stable
* @category predicates
* @since 2.0.0
*/
export declare const some: (collection: Iterable) => boolean;
/**
* Reducer for combining `boolean`s using AND.
*
* **When to use**
*
* Use to require every accumulated boolean to be `true` through APIs that
* consume a `Reducer`.
*
* **Details**
*
* The `initialValue` is `true`, so `combineAll([])` returns `true`.
*
* **Gotchas**
*
* `combineAll` uses the default left-to-right `Reducer.make` fold and does not
* short-circuit on `false`.
*
* @see {@link ReducerOr} for reducing with OR semantics
* @see {@link every} for checking an iterable directly
*
* @stability stable
* @category math
* @since 4.0.0
*/
export declare const ReducerAnd: Reducer.Reducer;
/**
* Reducer for combining `boolean`s using OR.
*
* **When to use**
*
* Use to reduce boolean values where the result should be `true` if any
* combined value is `true`.
*
* **Details**
*
* The `initialValue` is `false`.
*
* @see {@link ReducerAnd} for reducing with AND semantics
* @see {@link some} for checking an iterable directly
*
* @stability stable
* @category math
* @since 4.0.0
*/
export declare const ReducerOr: Reducer.Reducer;
//# sourceMappingURL=Boolean.d.ts.map