Skip to content

separate R.where into two simpler functions: R.where and R.whereEq - #1036

Merged
buzzdecafe merged 1 commit into
ramda:masterfrom
davidchambers:where-pred
May 8, 2015
Merged

separate R.where into two simpler functions: R.where and R.whereEq#1036
buzzdecafe merged 1 commit into
ramda:masterfrom
davidchambers:where-pred

Conversation

@davidchambers

Copy link
Copy Markdown
Member

Closes #1032

This is the alternative to #1034. If we decide we want both functions we need to decide what to name them. :)

Comment thread test/where.js Outdated

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love to remove this special case.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@buzzdecafe

Copy link
Copy Markdown
Member

IMO where is about specifying an interface that the input object must satisfy, not that the object's individual properties must satisfy in isolation.

@megawac

megawac commented Apr 21, 2015

Copy link
Copy Markdown
Contributor

I'm fine with this as long as whereEq is included

whereEq = compose(where, mapObject(eq))

@CrossEye

Copy link
Copy Markdown
Member

Damn, it hadn't hit me how straightforward that conversion was:

whereEq = compose(where, mapObject(eq))

Nice.

@svozza svozza mentioned this pull request Apr 21, 2015
@davidchambers

Copy link
Copy Markdown
Member Author

Shall I add R.whereEq?

@CrossEye

Copy link
Copy Markdown
Member

I could be happy with this version of where alongside a whereEq. But I believe @buzzdecafe still might have some reservations about it.

@buzzdecafe

Copy link
Copy Markdown
Member

not reservations. just not seeing the point particularly.

@CrossEye

Copy link
Copy Markdown
Member

I say yes, then. Two simple functions beat one complex function hands-down.

@davidchambers davidchambers changed the title simplify R.where separate R.where into two simpler functions: R.where and R.whereEq May 4, 2015
@davidchambers

Copy link
Copy Markdown
Member Author

I've added R.whereEq.

Comment thread src/whereEq.js

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this valid use of the word specialization?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say so.

@davidchambers

Copy link
Copy Markdown
Member Author

((:bell:)) @buzzdecafe, @CrossEye

@buzzdecafe

Copy link
Copy Markdown
Member

i don't mind the complexity of the original. i don't really object to this, but it doesn't excite me either. i expect this may break a lot of stuff that uses where at present.

this is nice: return where(mapObj(eq, spec), testObj);
but i wonder how it performs? that was the reason for the nastiness of the original.

@davidchambers

Copy link
Copy Markdown
Member Author

i expect this may break a lot of stuff that uses where at present.

Certainly. In most cases, users will need to replace R.where with R.whereEq:

-R.where({x: 1, y: 2})
+R.whereEq({x: 1, y: 2})

In each of the remaining cases, each non-function value in the spec must be wrapped with R.eq:

-R.where({x: 1, y: 2, z: R.gte(R.__, 0)})
+R.where({x: R.eq(1), y: R.eq(2), z: R.gte(R.__, 0)})

@CrossEye

CrossEye commented May 8, 2015

Copy link
Copy Markdown
Member

Sorry, I thought I'd made it clear that I was in favor of this.

I do think that sometime soon, we'll have to look at the basic implementation. If I'm not mistaken, in the Great Curry Debacle of 2014, we reset this one in such a way that it might have lost some of the benefits that had been gained by the initial manual currying we had done. This one was the function that showed us the need for changes to our old currying, and it had some interesting behavior...

buzzdecafe added a commit that referenced this pull request May 8, 2015
separate R.where into two simpler functions: R.where and R.whereEq
@buzzdecafe
buzzdecafe merged commit 75cc61b into ramda:master May 8, 2015
@megawac

megawac commented May 8, 2015

Copy link
Copy Markdown
Contributor

Let's just make sure this is bold, highlighted, underlined in change log as
it will break a good amount of code
On May 8, 2015 10:46 AM, "Michael Hurley" notifications@github.com wrote:

Merged #1036 #1036.


Reply to this email directly or view it on GitHub
#1036 (comment).

@buzzdecafe

Copy link
Copy Markdown
Member

yep, totally agree

@davidchambers
davidchambers deleted the where-pred branch May 8, 2015 16:59
@buzzdecafe

Copy link
Copy Markdown
Member

not sure what to make of this: http://jsperf.com/mapobj-test

@davidchambers

Copy link
Copy Markdown
Member Author

I could certainly get behind a more efficient implementation. It was API complexity this pull request sought to reduce.

Comment thread src/where.js

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason you're not using keys here (it'd be faster)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a good idea to me!

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

Successfully merging this pull request may close these issues.

simplify R.where

4 participants