Support for `curry`
Hello, @raon0211 !
As I mentioned at #133 , I would start work on curry!
Sure!
I was really happy to hear that es-toolkit decided to support the curry function!!
I'm curious about your thoughts on implementing a strict rule for currying, where if a function takes multiple arguments, it transforms them into a composition of single-argument functions. This approach is a bit different from the lodash specification, which I will explain further.
The curry function in lodash doesn't strictly enforce the rules of currying, and is more like providing partial application rather than true currying.
I think one reason why developers often get confused between currying and partial application is because popular libraries like lodash use these terms incorrectly 😢
Therefore, I would like to suggest designing es-toolkit to follow the correct definition of currying strictly!
However, this might make it harder to gain users since it wouldn't be a drop-in replacement for those who are used to lodash.
@evan-moon THANK YOU FOR GOOD SUGGESTION! Indeed, the curry method provided by existing libraries like Lodash has a different form compared to the 'strict type of currying'. However, I believe that many developers, including myself, are familiar with the usage of this 'flexible type of currying' provided by these libraries.
In fact, I am now implementing a 'flexible type of currying'. However, after reading your suggestions, I think it is important to respect the traditional method to enhance the depth of the library.
How about this approach?
- Implement both 'strict type of currying' and 'flexible type of currying'.
- In the documentation, guide developers who want a 'Lodash-style curry' to look for 'flexible type of currying'(ex.
curry.flexibleorpartial.chain).
By implementing it this way, although users might be confused at first, I believe it is a valuable process to correct any misconceptions.
@evan-moon Based on the suggestions provided and my reply, I have created draft PR #187!
Please check it out and feel free to leave any comments & ideas!
@evan-moon Based on the suggestions provided and my reply, I have created draft PR #187!
Please check it out and feel free to leave any comments & ideas!
Thank you. Let's continue the discussion in that PR! 👍
Now curry and curryRight have been fully implemented!
Thank you @D-Sketon 🙏 Then this issue can be closed now!