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

Idea: opt-in auto-curry? #90

Open
tomek-he-him opened this issue May 25, 2015 · 12 comments
Open

Idea: opt-in auto-curry? #90

tomek-he-him opened this issue May 25, 2015 · 12 comments

Comments

@tomek-he-him
Copy link
Member

I’ve never really had the time to get my hands on it, but AFAIK pure functional languages come with currying out of the box.

I like it how 1-liners stays lean – without dependencies – without inter-module imports – without auto-currying and other fancy. But I often find myself currying half of the 1-liners functions I import.

How about creating another repo with all functions auto-curried by default? With chickencurry or something.

import between from '1-liners-plus/between';

between(1, 10, 2.5) ===
between(1)(10, 2.5) ===
between(1, 10)(2.5) ===
between(1)(10)(2.5);
@tomek-he-him
Copy link
Member Author

1-liners-plus can be auto-generated like our index.

It can also just be a folder in this repo:

  • import between from '1-liners/curried/between'
  • or: import between from '1-liners/between/curried'

@stoeffel
Copy link
Contributor

That's what I proposed in #17. I would prefer a separate repo to keep the repo clean.

👍 for using chickencurry 😄 but maybe it is cleaner if we use 1-liners/curry (more predictable)

Names:

  • 1-liners-curry
  • curried-1-liners
  • 1-curries

@tomek-he-him
Copy link
Member Author

but maybe it is cleaner if we use 1-liners/curry (more predictable)

Yeah, but I think we really want a haskell-like

f(1, 2, 3, 4) ===

f(1)(2, 3, 4) ===
f(1, 2)(3, 4) ===
f(1, 2, 3)(4) ===

f(1, 2)(3)(4) ===
f(1)(2, 3)(4) ===
f(1)(2)(3, 4) ===

f(1)(2)(3)(4);

With 1-liners/curry we only get:

f(1)(2, 3, 4) ===
f(1, 2)(3, 4) ===
f(1, 2, 3)(4);

@tomek-he-him
Copy link
Member Author

That's what I proposed in #17.

Sorry, I didn’t quite get it back then :) That was absolutely a good idea.

@stoeffel
Copy link
Contributor

Sorry, I didn’t quite get it back then :)

Np

Yeah, but I think we really want a haskell-like

Yop, you are right that could be done with chickencurry. If we go with that I will add you guys as collaborators. Would be nice to make it even more awesome.

@tomek-he-him
Copy link
Member Author

In the best case:

//  ▤ chickencurry/_.js
export const _ = Symbol();
import _ from 'chickencurry/_';

f(1, 2, 3, 4) ===
f(_, _, 3, _)(1, 2, 4);

@stoeffel
Copy link
Contributor

👍 for changing the placeholder to a Symbol.

but I guess you meant?

f(1, 2, 3, 4) ===
chickencurry(f)(_, _, 3, _)(1, 2, 4);

@tomek-he-him
Copy link
Member Author

Jain :) I meant

import f from '1-liners-curried/f';

@stoeffel
Copy link
Contributor

I will get started on this on Saturday.

@stoeffel
Copy link
Contributor

Or if you guys are first you can give it a shot

@stoeffel
Copy link
Contributor

I'm working on separating the utils first. ( #72 )

@Siilwyn
Copy link

Siilwyn commented Nov 28, 2018

👋 chiming in, would love to have simplistic currying like Sanctuary does, think that aligns well with the intention of this project. So there is only one way to call a function which offers multiple benefits.

What about adding a second export to each function file besides the default which exports the curried function and extracting that during the build process to publish to e.g. 1-liners/curried. Thoughts?

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

No branches or pull requests

3 participants