Skip to content

Commit

Permalink
Either: fix fromOption overloads order (#2194)
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti authored and mikearnaldi committed Feb 21, 2024
1 parent 136ef40 commit 55b26a6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/mighty-horses-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

Either: fix `fromOption` overloads order
2 changes: 1 addition & 1 deletion packages/effect/src/Either.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ export const fromNullable: {
* @since 2.0.0
*/
export const fromOption: {
<R, L>(self: Option<R>, onNone: () => L): Either<R, L>
<L>(onNone: () => L): <R>(self: Option<R>) => Either<R, L>
<R, L>(self: Option<R>, onNone: () => L): Either<R, L>
} = either.fromOption

const try_: {
Expand Down
5 changes: 4 additions & 1 deletion packages/effect/src/internal/either.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ export const getRight = <R, L>(
): Option<R> => (isLeft(self) ? option.none : option.some(self.right))

/** @internal */
export const fromOption = dual(
export const fromOption: {
<L>(onNone: () => L): <R>(self: Option<R>) => Either.Either<R, L>
<R, L>(self: Option<R>, onNone: () => L): Either.Either<R, L>
} = dual(
2,
<R, L>(self: Option<R>, onNone: () => L): Either.Either<R, L> =>
option.isNone(self) ? left(onNone()) : right(self.value)
Expand Down

0 comments on commit 55b26a6

Please sign in to comment.