Build a law from a name, a predicate, an optional note, an arbitrary for the predicate arguments, and optional fast-check runtime parameters. The runtime parameters are documented here.

import fc from 'fast-check'
import {Law} from 'effect-ts-laws'
const law: Law<[number, number]> = Law(
'sum of positives ≥ both', // • law name
'∀a,b in N, sum=a+b: sum≥a ∧ sum≥b', // • law note
fc.integer(), // • list of
fc.integer(), // arbitraries
)( // required for...
(x, y) => x + y >= x && x + y >= y, // • the law predicate
{numRuns: 10_000} // • optional runtime config
)
  • Type Parameters

    • Ts extends UnknownArgs

      Argument type of predicate. For example, if the law predicate signature is Predicate<[a: number, b: string]>, then T would be [a: number, b: string].

    Parameters

    • name: string

      Law name, shown as test label.

    • note: string

      String note to be shown on failure or in verbose mode.

    • Rest...arbitraries: {
          [K in string | number | symbol]: Arbitrary<Ts[K<K>]>
      }

      A tuple of arbitraries, one per predicate argument.

    Returns ((predicate: ((...args: Ts) => boolean), parameters?: Parameters<[Ts]>) => Law<Ts>)

      • (predicate, parameters?): Law<Ts>
      • Parameters

        • predicate: ((...args: Ts) => boolean)

          Law predicate. Its argument type is encoded in Ts.

            • (...args): boolean
            • Parameters

              • Rest...args: Ts

              Returns boolean

        • parameters: Parameters<[Ts]> = {}

          fast-check runtime parameters.

        Returns Law<Ts>