effect-ts-laws
    Preparing search index...

    arbitrary

    fast-check utilities and arbitraries for effect-ts datatypes.

    Every type and function here can be imported directly from effect-ts-laws.

    Example

    Importing arbitraries from this package:

    import {Option as OP, pipe} from 'effect'
    import {tinyArray, tinyInteger, option} from 'effect-ts-laws'
    import fc from 'fast-check'

    const arbitrary: fc.Arbitrary<OP.Option<number>[]> = pipe(
    tinyInteger,
    option,
    tinyArray
    )

    Monad instance for the fast-check Arbitrary type, and a type lambda for the type.

    There is also an Equivalence instance which will try to find counterexamples to the equivalence and return true if none found.

    Example

    Using the flatMap function:

    import {Effect as EF, flow, pipe} from 'effect'
    import {Monad} from 'effect-ts-laws'
    import fc from 'fast-check'

    const greaterThanOne = (i: number): EF.Effect<string, Error> =>
    i > 1 ? EF.succeed('OK') : EF.fail(new Error('KO'))

    const oneThirdFail: fc.Arbitrary<EF.Effect<string, Error>> = pipe(
    fc.integer({min: 1, max: 3}),
    Monad.flatMap(flow(greaterThanOne, fc.constant)),
    )