-
-
Notifications
You must be signed in to change notification settings - Fork 502
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
Enhancement: Eq<A>.equals curried by default for more ergonomic use #1284
Comments
I think the same should apply then to the compare method of the |
Could anyone offer a reason not to curry absolutely everything by default? It opens up partial application, and if you don't want to partially apply then |
If we're going to go whole hog, then I'd like to point out that when you
these two functions do not have the same type signature. One is curried, and the other is not. This surprised me and has made for less ergonomic code when writing functions that take a monad Originally I was writing
but wanted to inject the monad:
|
I think it's better to stick to one invocation, and curry only the data structure for piping ergonomics. In this P.S. |
@samhh We went this road once in the times of
Yeah, I suggested it to @gcanti. At the moment it is in the backlog for |
When we are talking about Current definition ( export interface Ord<A> extends Eq<A> {
readonly compare: (first: A, second: A) => Ordering
}
assert.deepStrictEqual(
pipe(1, (x) => ordNumber.compare(x, 2)),
-1
) Currying ( export interface Ord<A> extends Eq<A> {
readonly compare: (first: A) => (second: A) => Ordering
}
assert.deepStrictEqual(
pipe(1, (x) => ordNumber.compare(x)(2)),
-1
) Data-last ( export interface Ord<A> extends Eq<A> {
readonly compare: (second: A) => (first: A) => Ordering
}
assert.deepStrictEqual(pipe(1, ordNumber.compare(2)), -1) |
Personally when I request or otherwise discuss currying, data-last is implied, so it's the third example there. |
Ok, closing in favour of #1216 |
Right now if I am doing a filter-type operation, the predicate type takes one param and returns boolean.
Eq<A>.equals
takes two params (items to be compared) and returns boolean.So using
equals
as the predicate for afilter
-type operation, I do as such:If instead
Eq<A>.equals
were written to bethen you could write
Small thing, but I've run into it a few times and thought the code would be more readable if
equals
were curried like this.The text was updated successfully, but these errors were encountered: