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

Suggestions #147

Closed
selfrefactor opened this issue Apr 18, 2019 · 59 comments
Closed

Suggestions #147

selfrefactor opened this issue Apr 18, 2019 · 59 comments
Labels

Comments

@selfrefactor
Copy link
Owner

selfrefactor commented Apr 18, 2019

This issue is opened to encourage suggestions and feedback.

Vote for bringing even more Ramda methods in Rambda


@selfrefactor
Copy link
Owner Author

selfrefactor commented Apr 18, 2019

Deprecate R.contains as Ramda has already did it?

@selfrefactor
Copy link
Owner Author

Introduce R.project https://ramdajs.com/docs/#project

@selfrefactor
Copy link
Owner Author

R.pickBy https://ramdajs.com/docs/#pickBy

@kuchta
Copy link

kuchta commented May 9, 2019

Could forEach be enhanced to work on Objects as well as Arrays as map and filter do to match Ramda's forEachObjIndexed which Rambda has not counterpart?

@selfrefactor
Copy link
Owner Author

Could forEach be enhanced to work on Objects as well as Arrays as map and filter do to match Ramda's forEachObjIndexed which Rambda has not counterpart?

This is nice suggestions. I will post spec once the new behavior is written, so you can confirm it.

@selfrefactor
Copy link
Owner Author

@kuchta I will have to ask for collaboration as if you look at the source of forEach, you will see that it already passes to R.map. I only changed R.map implementation and now iterator function accept third argument namely the input object. This change is published with version 2.6.0

@StreetStrider
Copy link
Contributor

Expose src/ as es/ for Rollup, so I could import curry from 'rambda/es/curry'.

@selfrefactor
Copy link
Owner Author

@StreetStrider src was removed per previous request, but I don't mind exposing it back as Ramda also exposes its src folder. Can you share reasoning why it should be exported as es folder?

@StreetStrider
Copy link
Contributor

@selfrefactor for me, actual name here is a matter of clarity. Names, like es/, cjs/ or .umd.js are much clear in pointing at format of specific modules, while src/ and lib/ indicates that here are original files (which may be unconsumable by default).

es is better than src, but src is OK too.

selfrefactor added a commit that referenced this issue May 16, 2019
@selfrefactor
Copy link
Owner Author

I thank you @StreetStrider for the clarification. The latest version 2.7.1 exposes src per your request.

@StreetStrider
Copy link
Contributor

@selfrefactor I've tried npm i in this package today and got difficulties. I can't install all dependencies (erros like pathspec '2.0.0' did not match any file(s) known to git.). Can you confirm that you are able to install dependencies from scratch (rm -rf node_modules then npm i)?

@selfrefactor
Copy link
Owner Author

I can confirm the same bug. It seems that you will have to use yarn for this purpose. Another strange case where yarn works where npm does not. I have some other similar cases so nothing new.

@StreetStrider
Copy link
Contributor

I've tried install deps one-by-one, error occurs here:

↳ p i 'selfrefactor/minify#0.1.0'     
 ERROR  Could not resolve 2.0.0 to a commit of git://github.com/sindresorhus/figures.git.

So it is most likely a bug in transient dep of selfrefactor/minify.
Maybe you should try update sindresorhus/figures version.

@selfrefactor
Copy link
Owner Author

@StreetStrider I simply removed figures dependency from minify library and now it works with NPM as well.

@StreetStrider
Copy link
Contributor

@selfrefactor good to know. Environment must be reproducible for others.

@romgrk
Copy link
Contributor

romgrk commented May 30, 2019

Implement lenses functions.

@selfrefactor
Copy link
Owner Author

@romgrk this has been brought up before and I will welcome any PR that addresses lenses integration, but I am not using them and it will be a bit hard for me to write the logic.

@romgrk
Copy link
Contributor

romgrk commented Jun 3, 2019

Sure, I understand. Brian Lonsdorf has a pretty straight-forward implementation of lenses here, I wonder if we could just re-use that one.
I use rambda for pretty much all my needs, but I do need to import ramda in most projects just to get those lenses.

@selfrefactor
Copy link
Owner Author

Thanks for the link @romgrk , but I guess you will have to use ramda for anything regarding lenses. After all the niche of Rambda is to provide partial API for the base methods in ramda. What I can do is to try to apply the suggested link initially in Rambdax and then bring it here. I will write once this initial application is ready.

@romgrk
Copy link
Contributor

romgrk commented Jun 3, 2019

Other suggestion, I notice that the signature for some methods is sometimes not exactly the same as ramda. Is it possible to make it 100% compatible? (e.g. ramda.adjust(index, fn, list) vs rambda.adjust(fn, index, list))
Note that the JSDoc of that function (and possibly others) is also wrong (bad signature).
Note that even though the JSDoc says negative indexes are ok for adjust, they're not handled in the function.
Can I submit a PR for these issues? (not the lenses)

@selfrefactor
Copy link
Owner Author

Sure, JSDoc annotations is a recent PR which was pretty big and as you noticed there are obvious inconsistencies. Your PR fixing these issues is very welcome.

@romgrk
Copy link
Contributor

romgrk commented Jun 3, 2019

Ok, is it fine if I modify rambda's API to match ramda one, rather than modify the jsdocs?

@selfrefactor
Copy link
Owner Author

selfrefactor commented Jun 3, 2019

You will have to check the entry in the intro of README.md for the known differences between Rambda and Ramda as this differences are made on purpose.

@romgrk
Copy link
Contributor

romgrk commented Jun 3, 2019

They're made on purpose? It would be more convenient for users to have the same API.
But can you just confirm that you're ok if I submit a PR that modifies rambda's API?

@selfrefactor
Copy link
Owner Author

It is almost the same. I try to extend rather than change existing behavior. I am fine with modification as long as they are not related to the known differences.

@selfrefactor
Copy link
Owner Author

@romgrk Your changes are live with the new version. Thanks for the input and I will keep you updated when there is progress with lenses.

@kuchta
Copy link

kuchta commented Jun 5, 2019

It would be great to have typings directly in the source code (making the source code effectively TypeScript) to prevent it to get out of sync with the code.

@selfrefactor
Copy link
Owner Author

@kuchta I am unsure what you mean. Do you mean something like Flow? Even so, I am unsure how well it works with curried function as this is an issue with Typescript

@kuchta
Copy link

kuchta commented Jun 5, 2019

@selfrefactor I meant to put typings directly into sourcecode and rename it from js to ts :)

@StreetStrider
Copy link
Contributor

@selfrefactor I looked through your code, and everywhere you use «manual» currying, without explicitly depending on curry. The same trick can be applied to typings both Flow and TS, via function overload, you just need to declare function signature multiple types. Something (pseudocode) like this:

foo(A, B) => R
foo(A) => foo(B) => R

TS overloads.
Flow docs is bad, but it can be done too, via multiple declare function.

@selfrefactor
Copy link
Owner Author

@StreetStrider I tried this approach before, but I wasn't happy with the output for Typescript typings(i.e. index.d.ts). But I guess it is possible to keep the current typings and ignore those produced by tsc build. I will give it a try and thank you for your input on the subject.

@selfrefactor
Copy link
Owner Author

@kuchta My recent work experience changed the way read any code and now I try to be as simple as possible. This means that I am not very eager to understand and implement lenses, but as I had said before, this doesn't mean that I will reject any PR that addresses this feature request.

@damiangreen
Copy link

I'm evaluating rambda as an alternative over ramda for the cases where it doesnt type wel lfor the compose and pipe operators , e.g. (https://stackoverflow.com/questions/54363310/how-to-remove-unnecessary-casting-with-ramda-and-typescript). It still appears to suffer the same drawbacks. Is there any intention to improve upon this?

@selfrefactor
Copy link
Owner Author

selfrefactor commented Aug 22, 2019

Still wating for this Typescript issue to be addressed. Until then, there is not much that it could be done in this regard.

Personaly me, I stopped using compose and pipe with my Typescript code as there is no easy way around it.

One crazy solution is to have two methods for curried and uncurried version, i.e. R.foo and R._foo and then we'll be able to write this library with Typescript and let it create the final typings. But this is mad science and I brought it just to illustrate even further that currently this is not a simple matter.

@squidfunk
Copy link
Contributor

Ramda methods I miss in Rambda:

  • intersection, intersectionWith
  • difference, differenceWith
  • intersperse
  • lensPath
  • set

@selfrefactor
Copy link
Owner Author

As stated before, lenses are hard for me to implement, so unless somebody opens a PR, they will be lacking in Rambda.

As for the other 5 suggestions - I will implent them with the version after the next one as now I am in the middle of writing typings tests.

Thank you for your suggestions @squidfunk

@squidfunk
Copy link
Contributor

I went ahead and implemented the set functions in four separate PRs. They can be generalized to the *With versions later on. I also tried to stick to your coding style. Would love to see them in the next release :-)

@selfrefactor
Copy link
Owner Author

selfrefactor commented Sep 17, 2019

Great job @squidfunk
I approved all of PRs and I will try to make a release this weekend, even though I am not completely ready with typings refactor caused by typings tests. Thanks again.

@squidfunk
Copy link
Contributor

That's great news! I also realized that I can simplify a situation where I used lensPath and set to assocPath. Will try to submit a PR for this, too.

@squidfunk
Copy link
Contributor

There was an error merging the typings - missing /*:

rambda/index.d.ts

Lines 351 to 355 in 33ed7fc

* Combines two lists into a set (i.e. no duplicates) composed of those elements common to both lists.
*/
intersection<T>(list1: ReadonlyArray<T>, list2: ReadonlyArray<T>): T[];
intersection<T>(list1: ReadonlyArray<T>): (list2: ReadonlyArray<T>) => T[];

@selfrefactor
Copy link
Owner Author

I think the last warning is fixed as tests are passing(including the typing tests)

@squidfunk
Copy link
Contributor

@selfrefactor I fixed it in my PR ;-)

@polls polls bot added the Polls label Oct 15, 2019
@gotenxds
Copy link
Contributor

gotenxds commented Nov 23, 2019

Any way we can add set as an alias to assocPath ?
Maybe even get and getOr as aliases for path and pathOr some coming from lodash would find this easier to read.

@gotenxds
Copy link
Contributor

Can we make indexBy accept a Path | (a: T) => string so we can use it like this ?

indexBy('id', [{ id: 1 }, { id: 2 }, { id: 3 }])

@selfrefactor
Copy link
Owner Author

For the aliases - my issue is that they shouln't be a first class methods and this brings many other problems. For example, how I update all the aliases when a Typescript definition change? Should I leave them out of Ramda definition file?

I will keep your suggestion alive, but for the moment I have to decline it. Still, it is very possible that this change in the future. I will inform you if that happens.

As for indexBy - can you post your expectations for your example?

@gotenxds
Copy link
Contributor

indexBy could take either a function or a path to the property
so you could either do this:

indexBy(obj => obj.id, [{ id: 1 }, { id: 2 }, { id: 3 }])
// same as
indexBy('id', [{ id: 1 }, { id: 2 }, { id: 3 }])

this could be dont using path so it would support nesting

indexBy(obj => obj.a.b.c.id, [{ a: { b: { c: { id: 1  } } } }, { a: { b: { c: { id: 2  } } } }, { a: { b: { c: { id: 3  } } } }])
// same as
indexBy('a.b.c.id', [{ a: { b: { c: { id: 1  } } } }, { a: { b: { c: { id: 2  } } } }, { a: { b: { c: { id: 3  } } } }])

@selfrefactor
Copy link
Owner Author

Ok, that helped.
You can check this file 'src/indexBy.spec.js' where I added a specification for your suggestion. I will try to move it forward with Typescript definitions and the new functionallity should land with version 4.4.0

@gotenxds
Copy link
Contributor

Great ^^ if you need help with that I can make a small PR for that stuff

@selfrefactor
Copy link
Owner Author

I am almost there so I guess there is no need for PR. I just have one more task before releasing 4.4.0 but I should be ready soon.

@devdoomari3
Copy link

devdoomari3 commented Dec 27, 2019

maybe this can be "ramda/fp" like "lodash/fp" ?
(and become part of ramda and make ramda-team maintain this? 😉 )

searching for "rambda js" after reading blog-post gives me results for "ramda js" 😞

@gotenxds
Copy link
Contributor

gotenxds commented Dec 27, 2019

maybe this can be "ramda/fp" like "lodash/fp" ?
(and become part of ramda and make ramda-team maintain this? 😉 )

searching for "rambda js" after reading blog-post gives me results for "ramda js" 😞

Ramda is already fb, the main difference between rambda and ramda is tree shaking support out of the box and better performance.
Only thing missing now is full TS support as currently it causes compilation errors, @selfrefactor move to TS cough cough ;)

image

@selfrefactor
Copy link
Owner Author

@gotenxds as for your previous comment - please post solution. In other words - you can edit directly Rambda's index.d.ts file in your node_modules and confirm what change fixes the error. I think that the change is the same as my last commit a few minutes ago, but I just want to make sure of it. Also I will do a release once we agree on a fix.

@jcdietrich
Copy link

I would like to see cond added.

@selfrefactor
Copy link
Owner Author

@jcdietrich Will do

R.cond is useful method - #373

@please-rewrite
Copy link

Any chance chain (fantasy-land) can be added to this library. 😬

@tjklemz
Copy link

tjklemz commented Mar 25, 2020

Any chance chain (fantasy-land) can be added to this library. 😬

Ditto. https://ramdajs.com/docs/#chain

@selfrefactor
Copy link
Owner Author

selfrefactor commented Mar 25, 2020

@please-rewrite @tjklemz Sure, no problem.

I created issue for that - #408 but it will take at least two weeks until it is implemented, as right now I make big changes in terms of supporting scripts(build documentation, build Rambdax, generate typings, sync with Ramda test, increase dtslint tests).

The feature should be implemented with 5.1.0 and I can ping you once that happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests