Skip to content

make

make<A, B>(f): Refinement<A, B>

Defined in: Core/Refinement.ts:45

Creates a Refinement<A, B> from a plain boolean predicate.

This is an unsafe cast — the caller is responsible for ensuring that the predicate truly characterises values of type B. Use this only when bootstrapping a new refinement; prefer compose, and, or or to build derived refinements from existing ones.

A

B

(a) => boolean

Refinement<A, B>

type PositiveNumber = number & { readonly _tag: "PositiveNumber" };

const isPositive: Refinement<number, PositiveNumber> =
  Refinement.make(n => n > 0);