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

Accept plain functions in combinators #154

Closed
wants to merge 1 commit into from

Conversation

gustavoguichard
Copy link
Collaborator

@gustavoguichard gustavoguichard commented Jun 22, 2024

This is a work in progress for a POC.
The idea is to be able to accept any function in combinators, so we simplify their usage:

const add = (a: number, b: number) => a + b

// from:
const fn = collect({ add: composable(add), toString: map(composable(add), String) })

// to:
const fn = collect({ add, toString: map(add, String) })

TODO:

  • Fix the BranchReturn type
  • Fix some types responsible for merging parameters of functions - when testing collect with a composable and a plain function the parameters resolved to never.

@diogob
Copy link
Contributor

diogob commented Jun 22, 2024

Interesting idea.

@@ -270,12 +281,13 @@ function catchFailure<
(
...args: Parameters<Fn>
) => Awaited<ReturnType<C>> extends never[]
? UnpackData<Fn> extends any[] ? UnpackData<Fn>
: Awaited<ReturnType<C>> | UnpackData<Fn>
? UnpackData<Fn> extends any[]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like prettier, lets keep deno fmt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is far from done. I'm gonna clean it up once it starts to get serious ;)

@gustavoguichard
Copy link
Collaborator Author

Closing it in favor of #155

@gustavoguichard gustavoguichard deleted the wrap-composables branch June 24, 2024 21:18
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.

2 participants