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

Flip the arguments of a curried function #1748

Merged
merged 5 commits into from
Sep 1, 2022
Merged

Conversation

thewilkybarkid
Copy link
Contributor

I've been using this flipC in combination with Reader's local to hide implementation details, based on https://andywhite.xyz/posts/2021-01-28-rte-react/#service-layers-and-implementation-hiding (e.g. https://github.com/PREreview/prereview.org/blob/35278c267c541586f7ca505b9bd9f5a634ec3e93/src/app.ts#L81).

This function dates back to @jskeate's suggestion in https://functionalprogramming.slack.com/archives/CPKPCAGP4/p1655736152988389?thread_ts=1655730853.886439&cid=CPKPCAGP4.

Another option could be to overload flip, though I've not tried that.

Co-authored-by: Jonathan Skeate <jskeate@bericotechnologies.com>
@samhh
Copy link
Contributor

samhh commented Aug 23, 2022

This is one of the few cases where I used a conflicting name in fp-ts-std - I don't think uncurried functions should get the proper name flip in a FP library.

Could we perhaps target a breaking change in 3.0 that rewrites flip to the curried version in this PR (and optionally renames uncurried flip to something else)? v3 includes other curry-friendly breaking changes.

@gcanti gcanti added this to the 2.13 milestone Aug 31, 2022
@thewilkybarkid
Copy link
Contributor Author

I've pushed 20268fc based on @samhh's suggestion to replace the existing flip: I've deprecated two arguments in favour of a new function flipArgs.

Not sure which approach you'd rather take @gcanti.

@gcanti
Copy link
Owner

gcanti commented Sep 1, 2022

Could we perhaps target a breaking change in 3.0 that rewrites flip to the curried version in this PR

I agree, I would:

  • add the export function flip<A, B, C>(f: (a: A) => (b: B) => C): (b: B) => (a: A) => C overloading to the existing flip function
  • deprecate the existing export function flip<A, B, C>(f: (a: A, b: B) => C): (b: B, a: A) => C signature
  • keep the @since 2.0.0 tag
  • do not export a flipArgs function

@thewilkybarkid
Copy link
Contributor Author

@gcanti Should be sorted now.

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