-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
types of fold #370
Comments
Ah, sorry. #336 was closed because it's a breaking change, and it has been fixed in the latest version |
I'm not using the beta version, what is beta about it? And what work is left before the next version? Maybe I can help. I've seen many fixes now in the 12 version. |
It's in beta because I wanted to accumulate all breaking changes for one major release. I plan to release it in the stable channel once all planned breaking changes, and Fluenture, are finished. The code itself should be "bug-free" and usable. See upgrade guide for a list of breaking changes included so far. You can install this version with
The following are the remaining planned breaking changes to implement. You can help with these if you like:
For the completion of Fluenture, the following is required:
|
I stated with the beta version, and reading the upgrade guide, however when i do pipe(
...,
fold<LA, RA, Error, RB>(..),
promise It's not very clear how |
What about making export function coalesce <LA, RB>(lmapper: (left: LA) => RB): <RA>(rmapper: (right: RA) => RB) => <LB>(source: FutureInstance<LA, RA>) => FutureInstance<never, RB> I suppose that should be because some throw, like in the case of
but not sure if that's a problem of Also in general add the generic export function bimap<LA, LB>(lmapper: (reason: LA) => LB): <RA, RB>(rmapper: (value: RA) => RB) => (source: FutureInstance<LA, RA>) => FutureInstance<LB, RB> ts infers way better the bimap type. |
@edgarjrg I have not had any feedback regarding the usage of Fluture beta with TypeScript, so this is very valuable. It seems some of the problems you are experiencing have to do with the unused generics in many of these functions. I plan to get rid of these: #337 - so instead of using Moving the generics into the nested functions where they are used seems like a great idea. I did not even know it's possible. Please feel free to submit a PR! :D |
Sure ! totally on board 👍 i really like this library. |
Why would the I guess that the point i want to make is that |
Consider the following expression: 1 | reject (42) |> // Future<Number, ?>
2 | chain (x => resolve (`${x}!`)) |> // Future<Number, String>
3 | fold (x => x) (x => x.length) |> // Future<?, Number>
4 | chain (_ => reject (null)) // Future<Null, Number>
Anywhere you're seeing
Only if you consider coalesce in isolation. Combined with chain, a user can, as demonstrated. Does this answer your question? |
Thank you for your explanation 🙏 The properties of I added dtslint to check types in this commit(It's very clumsy, mostly prove of concept/setup to add tests to types, sorry) this way we can add expressions and test if the types behave as expected, please run I hope we could add all expressions we would like to be possible in the tests, I used an approach of As far as i got,
I also looked into npm-ramda which uses a similar approach to validate types and tests types+returns at the same time, pretty neat, maybe we could do something like that. I failed to understand #230 , i tried to recreate the scenario but the tests do not seem to benefit at all with that change, maybe the real code has the noted exception but the given example works fine with |
Let's continue the discussion about never/unknown in the relevant issue: #337 (comment) |
- Revert #230 and reintroduce the usage of the 'never' type - Relax the signature of chain and chainRej to allow TypeScript to derive types when merging a Future of a never with a Future of a real type. Closes #337 and closes #370. - Move generic types closer to where they are used in the function signature. Closes #372 and closes #373 through supersession. Co-authored-by: Edgar Rodriguez <edgarj.rodriguezg@gmail.com>
Hi !
The type of fold (or coalesce as proposed) is
I think it should be
ok, maybe the never shouldn't be there, but the
lmapper
seems wrong.The text was updated successfully, but these errors were encountered: