-
Notifications
You must be signed in to change notification settings - Fork 439
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
[arrow-core] Make param names more dev friendly #853
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point is that the rest of the library is coded as fa / fb following usual FP naming conventions. So, even if I could get use to this we would probably need a similar approach for the whole library. That's my concern.
@@ -123,16 +123,19 @@ sealed class Try<out A> : TryOf<A> { | |||
} | |||
} | |||
|
|||
fun toOption(): Option<A> = fold({ None }, { Some(it) }) | |||
fun toOption(): Option<A> = fold({ None }, { | |||
arrayListOf<String>().fold |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JorgeCastilloPrz Indeed, we could either release this as per "module-basis" or "whole lib-basis", I personally would prefer the former as I cannot assure being able to work on this for a much longer period :) |
b53b487
to
0f1059e
Compare
|
Renaming inherited parameters causes a compiler warning for a good reason, as it conflicts on call-by-name for parameters! It's okay to have different parameter names for datatype functions, but anything in instances has to retain the parent's name. |
@raulraja Good to know! Is there anything we could do there from here? Is that ok to go with or a blocker? |
Codecov Report
@@ Coverage Diff @@
## master #853 +/- ##
============================================
- Coverage 44.88% 44.85% -0.03%
Complexity 628 628
============================================
Files 300 300
Lines 7709 7709
Branches 834 834
============================================
- Hits 3460 3458 -2
Misses 3947 3947
- Partials 302 304 +2
Continue to review full report at Codecov.
|
I'll be merging for now. Hopefully we can continue with the rename in other modules too. |
* Updated param names for Try * Updated param names for Either * Finished other data types in core module.
Current state
Currently in many DataTypes functions such as the common
fold
, have this format:The problem
Is common to find usages taking advantage of named parameters, in order to easily and quickly differentiate one function from the other. Such usages could look as follows with the current implementation:
Proposed solution
My proposal is to be more explicit with param names matching each possible case such as, for the Try example,
ifSuccess
andifFailure
.alternatively:
Scope
I've reduced the scope to only change non deprecated functions and those which have at least two parameters referring to a specific state, if applied.
Current progress:
Notes
Feel free to suggest better namings, I've mainly tried to match with Kotlin's similar functions, such as
fold
in Lists and so on. The rest are on my own subjective opinion.