effect-ts-laws
Version:
effect-ts law testing using fast-check.
13 lines • 968 B
JavaScript
import { Law, addLawSets, lawTests } from '#law';
import { pipe } from 'effect';
import { covariantLaws } from './Covariant.js';
import { unfoldGiven } from './given.js';
/**
* Typeclass laws for `SemiAlternative`.
* @category typeclass laws
*/
export const semiAlternativeLaws = (given, suffix) => {
const { F, equalsFa, fa } = unfoldGiven(given), { coproduct, coproductMany } = F;
return pipe(lawTests(`SemiAlternative${suffix ?? ''}`, Law('associativity', '(fa₁ ⊕ fa₂) ⊕ fa₃ = fa₁ ⊕ (fa₂ ⊕ fa₃)', fa, fa, fa)((fa1, fa2, fa3) => equalsFa(coproduct(coproduct(fa1, fa2), fa3), coproduct(fa1, coproduct(fa2, fa3)))), Law('coproductMany associativity', 'coproductMany(fa₁ ⊕ [fa₂, fa₃]) = coproduct(fa₁, coproduct(fa₂, fa₃))', fa, fa, fa)((fa1, fa2, fa3) => equalsFa(coproductMany(fa1, [fa2, fa3]), coproduct(fa1, coproduct(fa2, fa3))))), pipe(given, covariantLaws, addLawSets));
};
//# sourceMappingURL=SemiAlternative.js.map