-
Notifications
You must be signed in to change notification settings - Fork 14
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
Extracting primitives inspired by ATMP #119
Conversation
src/domain-functions.ts
Outdated
const [first, ...rest] = fns.map((df) => | ||
atmp(() => fromSuccess(df)(input, environment)), | ||
) | ||
return dfResultFromAtmp(A.all(first, ...rest))() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need the destructuring here?
Wouldn't this work?
const [first, ...rest] = fns.map((df) => | |
atmp(() => fromSuccess(df)(input, environment)), | |
) | |
return dfResultFromAtmp(A.all(first, ...rest))() | |
const results = fns.map((df) => | |
atmp(() => fromSuccess(df)(input, environment)), | |
) | |
return dfResultFromAtmp(A.all(results))() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not type check. I just assumed that the type was like that by design, but I could be wrong.
61476dc
to
71d9dbf
Compare
1a223fd
to
0469490
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I'd add a cf
alias to composable
given we already have mdf
and its success 🤭
to use a tagged union result. Reimplement collect in terms of all.
Inline some functions that were not really useful.
…nalagous to mapError on DFs
…arallel and pipe in sequence
I'm merging this one since it is backwards compatible and it seems that we are quite comfortable now with the direction it is taking. I'll hold the merge on the primitives type-safety for now. |
The goal here is to have primitives that don't need parsers and yet compose and handle errors in a similar way as domain functions do.
Unfortunately this won't provide true type safety on compositions, since these composable primitives will work with any
Composable
function types.However there are a few good use cases:
toComposable
with a fixed type on an already existing DF.fromComposable
and giving the parsers.without any sort of type-safety butwithout having to juggle awaits and exceptions.Inspired by the atmp library.
This PR is aiming at a "soft launch" where we can release a new version of the lib without breaking changes or any change in documentation.
TODO
traceFn
errors gracefullyComposable
compositions are type-safe (at least when all generics have been passed)