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

Support more than one generic argument. #5

Open
bakhtiyarneyman opened this issue Jul 30, 2019 · 1 comment
Open

Support more than one generic argument. #5

bakhtiyarneyman opened this issue Jul 30, 2019 · 1 comment

Comments

@bakhtiyarneyman
Copy link

Great library! It'd be even more useful if it supported Haskell's Either type.

@twop
Copy link
Owner

twop commented Jul 31, 2019

Thanks!
When I started the work of supporting generics I explicitly made the syntax compatible with 2 generic arguments.

// here what I envisioned
const Either = Union((a, b) => ({
  Right: of(a),
  Left: of(b)
}))

But at the time I didn't need it enough to justify the type mess this would cause.

But I did have an idea how to make the result type useful:
https://github.com/twop/ts-definitely-maybe/blob/master/src/result.ts

The gist of it is to bake one type argument at a time. Which is probably ok for result but less so for either.

Hope that helps + I'm open to discuss this more.

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

No branches or pull requests

2 participants