Package: effect
Module: Match
Matches values of type boolean.
When to use
Use to match primitive boolean values.
Details
This predicate refines unknown values to booleans, allowing pattern matching
on boolean types. It only matches the primitive boolean values true and false.
Example (Matching boolean values)
import { Match } from "effect"
const describeTruthiness = Match.type<unknown>().pipe(
Match.when(
Match.boolean,
(bool) => bool ? "Definitely true" : "Definitely false"
),
Match.when(0, () => "Falsy number"),
Match.when("", () => "Empty string"),
Match.when(Match.null, () => "Null value"),
Match.orElse(() => "Some other truthy value")
)
console.log(describeTruthiness(true)) // "Definitely true"
console.log(describeTruthiness(false)) // "Definitely false"
console.log(describeTruthiness(0)) // "Falsy number"
console.log(describeTruthiness(1)) // "Some other truthy value"
See
is for matching specific literal boolean valuesSignature
declare const boolean: Predicate.Refinement<unknown, boolean>
Since v4.0.0