Closed TheWix closed 1 year ago
That is correct, as per the docs: e.join()
is equivalent to e.chain(async x => x)
<-- notice the async part. The reason for that is that it's not possible to have an EitherAsync inside EitherAsync because it's a wrapper around Promise and promises automatically "join".
The solution here is to fix the type of ap
because result
has a type of EitherAsync<string, EitherAsync<string, void>>
which is not correct. Thanks for reporting, I'll try to resolve it shortly!
Regarding ap
, you are correct that is it awkward, it's not really suited for the object.method()
instead of method object
nature of purify.
In practice this means
-- Haskell
User <$> parseUsername username <*> parsePassword password <*> parseEmail email
becomes
// JS
parseEmail(email).ap(parsePassword(password).ap(parseUsername(username).map(User)))
Although I remember there was a more beautiful way to write the expression above, but I could be wrong.
Fixed in v1.3.5
Wow, quick turnaround! Thank you for pointing out my error, as well!
I also want to thank you for putting this library together. I was using fp-ts
before, but I found it was very difficult for people new to FP to pick it up. This library is not only a great way to learn the basics, but I have found it a great library to use in my day-to-day job.
I will hopefully be shipping some code with this shortly and then I can add my employer to your list of companies using it in Production!
So, I have something similar to the following:
Which types out fine. The result is
EitherAsync<string, void>
however, when I replace the![image](https://user-images.githubusercontent.com/362449/221928815-b46ca7cf-f7cc-4030-bbbe-a0f040dff0f9.png)
chain(identity)
withjoin()
I get a compiler error: