Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/Result.match #108

Merged
merged 4 commits into from
Feb 29, 2024
Merged

Conversation

jessekelly881
Copy link
Contributor

@jessekelly881 jessekelly881 commented Feb 23, 2024

Added Result.match helper and ran docgen.

* @category combinators
*/
export const match: {
<A, E, Ret>(options: MatchOptions<A, E, Ret>): (self: Result<A, E>) => Ret
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think inlining the options is ok.

options: {
  readonly onInitial: (_: Initial<A, E>) => X
  readonly onFailure: (_: Failure<A, E>) => Y
  readonly onSuccess: (_: Success<A, E>) => Z
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you mean? Instead of having a MatchOptions interface? It's used in multiple places though. What about just not exporting it?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to how .match is usually implemented in the effect modules: https://effect-ts.github.io/effect/effect/Either.ts.html#match

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It just means the type signature is more obvious at a glance, instead of having to jump to the interface to see all the options.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah gotcha. Makes sense. Updated :)

@tim-smart tim-smart merged commit 953ff58 into tim-smart:main Feb 29, 2024
3 checks passed
@github-actions github-actions bot mentioned this pull request Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants