diff --git a/.changeset/strong-falcons-exercise.md b/.changeset/strong-falcons-exercise.md new file mode 100644 index 0000000000..4e2e3688b6 --- /dev/null +++ b/.changeset/strong-falcons-exercise.md @@ -0,0 +1,5 @@ +--- +"effect": minor +--- + +Either: fix `getEquivalence` parameter order from `Either.getEquivalence(left, right)` to `Either.getEquivalence({ left, right })` diff --git a/packages/effect/src/Either.ts b/packages/effect/src/Either.ts index ba37261459..13974f6159 100644 --- a/packages/effect/src/Either.ts +++ b/packages/effect/src/Either.ts @@ -287,15 +287,15 @@ export const getLeft: (self: Either) => Option = either.getLeft * @category equivalence * @since 2.0.0 */ -export const getEquivalence = ( - EquivalenceL: Equivalence.Equivalence, - EquivalenceR: Equivalence.Equivalence -): Equivalence.Equivalence> => +export const getEquivalence = ({ left, right }: { + right: Equivalence.Equivalence + left: Equivalence.Equivalence +}): Equivalence.Equivalence> => Equivalence.make((x, y) => x === y || (isLeft(x) ? - isLeft(y) && EquivalenceL(x.left, y.left) : - isRight(y) && EquivalenceR(x.right, y.right)) + isLeft(y) && left(x.left, y.left) : + isRight(y) && right(x.right, y.right)) ) /** diff --git a/packages/effect/test/Either.test.ts b/packages/effect/test/Either.test.ts index f8448f0239..158b492114 100644 --- a/packages/effect/test/Either.test.ts +++ b/packages/effect/test/Either.test.ts @@ -177,7 +177,7 @@ describe("Either", () => { }) it("getEquivalence", () => { - const isEquivalent = Either.getEquivalence(S.Equivalence, N.Equivalence) + const isEquivalent = Either.getEquivalence({ right: N.Equivalence, left: S.Equivalence }) Util.deepStrictEqual(isEquivalent(Either.right(1), Either.right(1)), true) Util.deepStrictEqual(isEquivalent(Either.right(1), Either.right(2)), false) Util.deepStrictEqual(isEquivalent(Either.right(1), Either.left("foo")), false) diff --git a/packages/schema/src/Schema.ts b/packages/schema/src/Schema.ts index 90c9de2247..0bdc98aa9c 100644 --- a/packages/schema/src/Schema.ts +++ b/packages/schema/src/Schema.ts @@ -5193,7 +5193,7 @@ export const eitherFromSelf = ({ lef description: `Either<${format(left)}, ${format(right)}>`, pretty: eitherPretty, arbitrary: eitherArbitrary, - equivalence: (right, left) => Either.getEquivalence(left, right) + equivalence: (right, left) => Either.getEquivalence({ left, right }) } ) }