arbitrary

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

  1. Importing
  2. Modules
    1. monad
    2. data
    3. time
    4. function
    5. effect

Every type and function below can be imported directly from effect-ts-laws/arbitrary.

Example

Importing arbitraries from this package:

import {Option as OP, pipe} from 'effect'
import {tinyArray, tinyInteger, option} from 'effect-ts-laws/arbitrary'
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 counter-examples 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/arbitrary'
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)),
)
fast-check effect-ts instances

Arbitraries for some basic effect-ts datatypes.

data arbitraries

Arbitraries for effect-ts temporal types.

time arbitraries

Function arbitraries.

function arbitraries

Arbitraries for the Effect type.

effect arbitraries