effect-ts-laws
Version:
effect-ts law testing using fast-check.
34 lines • 1.21 kB
JavaScript
import { binary, liftArbitraries, option, unary, unaryToKind } from '#arbitrary';
import { liftEquivalences } from '#law';
import { pipe } from 'effect';
/**
* Unfold a {@link ParameterizedGiven} into all arguments required by predicates
* of parameterized typeclass laws.
* @param given - The options to unfold.
* @category harness
*/
export const unfoldGiven = (given) => {
const { a, b, c, equalsA, equalsB, equalsC, getArbitrary, getEquivalence } = given, [equalsFa, equalsFb, equalsFc] = liftEquivalences(getEquivalence)(equalsA, equalsB, equalsC), [fa, fb, fc] = liftArbitraries(getArbitrary)(a, b, c), endoA = unary()(a), ab = unary()(b), bc = unary()(c), ba = unary()(a), cb = unary()(b);
return {
...given,
equalsFa,
equalsFb,
equalsFc,
fa,
fb,
fc,
endoA,
ab,
bc,
ba,
cb,
bab: binary()(b),
afb: pipe(b, unaryToKind()(getArbitrary)),
bfc: pipe(c, unaryToKind()(getArbitrary)),
aob: pipe(b, option, unary()),
boc: pipe(c, option, unary()),
fabOf: (of) => ab.map(of),
fbcOf: (of) => bc.map(of),
};
};
//# sourceMappingURL=given.js.map