effect-ts-laws
Version:
effect-ts law testing using fast-check.
22 lines • 863 B
JavaScript
import { LawSet } from '#law';
import { Covariant as CO } from '@effect/typeclass';
import { identity, pipe } from 'effect';
import { dual } from 'effect/Function';
import { covariantLaws } from './Covariant.js';
/**
* Typeclass laws for `Bicovariant`.
* @category typeclass laws
*/
export const bicovariantLaws = (given, suffix) => {
const { F } = given;
const [mapFirst, mapSecond] = [
dual(2, (fa, ab) => pipe(fa, F.bimap(identity, ab))),
dual(2, (fa, od) => pipe(fa, F.bimap(od, identity))),
];
const [first, second] = [
{ map: mapFirst, imap: CO.imap(mapFirst) },
{ map: mapSecond, imap: CO.imap(mapSecond) },
];
return pipe(`Bicovariant${suffix ?? ''}`, LawSet(covariantLaws({ ...given, F: first }, '₁'), covariantLaws({ ...given, F: second }, '₂')));
};
//# sourceMappingURL=Bicovariant.js.map