arbitrary
fast-check
utilities and arbitraries for effect-ts
datatypes.
Every type and function below can be imported directly from
effect-ts-laws/arbitrary
.
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.
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)),
)
Arbitraries for some basic effect-ts
datatypes.
Arbitraries for effect-ts
temporal types.
Function arbitraries.
Arbitraries for the Effect
type.