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: Implement 'fromTry' for 'Either' #53

Merged
merged 1 commit into from
Apr 2, 2023

Conversation

wookieb
Copy link

@wookieb wookieb commented Nov 6, 2022

Related to #48

@JSMonk JSMonk merged commit 2aa70e8 into JSMonk:master Apr 2, 2023
@Lonli-Lokli
Copy link
Contributor

Lonli-Lokli commented Apr 3, 2023

Hi!

I would like to ask why do we have Either<L,R> and not Either<unknown, R> ? Errors are not strongly typed in Js

EDIT1. Also, with this sample from README

const a1 = fromTry(() => 2); // Either<never, number>.Right
    const a2 = fromTry(() => {
      throw new Error("test");
    }); // Either<Error, never>.Left

a1 has type Either<unknown, number>
a2 has type Either<unknown, never>

EDIT2
Same for fromPromise actually, and also
Returns Right with the promise value if the provided promise fulfilled or Left with the error value if the provided promise rejected.
I think it's incorrect as it will return Promise of Right or Left, not the Right\Left itself

@wookieb
Copy link
Author

wookieb commented Apr 4, 2023

@Lonli-Lokli You're obviously right! Fixed in another branch. Both addressed in #59

wookieb added a commit to wookieb/sweet-monads that referenced this pull request Jul 27, 2023
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.

3 participants