These are chat archives for ramda/ramda

7th
Jul 2016
Scott Christopher
@scott-christopher
Jul 07 2016 00:18
Woke up to 99+ new messages in this channel. Could only assume an operator order discussion had taken place .:D
I'd personally like to take the position of only offering unary functions in our library where the binary form is covered by a native operator, but I don't think there is a nice way to migrate to this in a backwards-compatible manner (nor is the position fully supported by everyone).
(well technically they would still be binary curried functions, but for the purposes of documentation I would refer to them as unary functions returning a unary function)
James Forbes
@JAForbes
Jul 07 2016 04:13

@CrossEye

If you think of them as unary predicates, one answer is obvious. But if you think of them as binary, the opposite one seems more likely.

What are you thoughts on:

if you have both arguments to supply to gt, you are not going to be point free. If you are not point free you therefore have the ability to use the native operator directly.
therefore, gt is only really useful in the unary form, therefore it's predicate nature should be prioritized

Could only assume an operator order discussion had taken place .

:D

@scott-christopher

but I don't think there is a nice way to migrate to this in a backwards-compatible manner

If your main concern is backwards compatibility, I guess that means you agree that gt's api should change, even if it (hypothetically) can't?
That is at least progress! :)

As @gabejohnson pointed out, the current gt's converse: lt has exactly the same functionality as my proposed changes.
A user who is upgrading to a minor version would only need to substitute R.gt for R.lt and they would be back in business.

So unlike most API changes, the migration is trivial. And Ramda making breaking changes in the past is not without precedent. I can think of many examples.

Usually the breaking changes are due to improved user experience, e.g. createMapEntry -> objOf

I personally don't have gt in any of my codebases because the current API just introduces confusion for coworkers.
I wonder how much impact such a migration would really have?

Scott Christopher
@scott-christopher
Jul 07 2016 04:17
The main concern with backwards compatibility would be that unless the functions were renamed in the process, they would still happily accept the same values that they do now, except return the opposite of what they originally intended.
That sounds like a not-fun outcome to discover by accident.
James Forbes
@JAForbes
Jul 07 2016 05:05

BTW the docs desperately need full text search, and extra disambiguation content.

Good point @barneycarroll

@scott-christopher

return the opposite of what they originally intended.

Except that many people are encountering that behaviour as it stands, because the current behaviour is surprising. So you have surprise either way.

Scott Christopher
@scott-christopher
Jul 07 2016 05:09
Right. The point was more so regarding people that have already R.flip(R.gt) or R.gt(R.__, 42) in production.
James Forbes
@JAForbes
Jul 07 2016 06:42
ah my mistake
all the same, one could still substitute gt for lt as a migration, even when they've flipped or used a placeholder.
Jigar Gosar
@jigargosar
Jul 07 2016 09:01
ramda's merge function doesn't copy property getter/setters?
any reason why?
I have derived properties, that need to be computed only when needed.
the merge function simply calls the getter and replaces it with it's value, was this the intended behaviour?
Scott Christopher
@scott-christopher
Jul 07 2016 09:44
@jigargosar R.merge now just delegates to Object.assign where it exists so the same semantics will apply, namely the values will be copied for all enumerable properties rather than the property descriptors.
Jigar Gosar
@jigargosar
Jul 07 2016 10:09
@scott-christopher thanks. I will have to define a custom function to copy prop discriptors.
Scott Sauyet
@CrossEye
Jul 07 2016 12:16
@JAForbes I worry very little about points-free. I think very much more about creating useful functions that capture the meaning is some of these operations. I think if we were doing it from scratch we might consider what @scott-christopher suggests, but that is a major breaking change. Maybe post 1.0.
"in some of these operations"
Drew
@dtipson
Jul 07 2016 14:30
obviously not one of the standard ones, but is this technically a combinator? const Q = () => Q;
Drew
@dtipson
Jul 07 2016 14:39
it's basically a Nothing function: was trying to explain combinators leading up to explaining what mapping over the Nothing type is doing (or not doing), but I'm not sure how to describe this form of it. The function's reference to itself might count as a free variable, I suppose
Lewis
@6ewis
Jul 07 2016 16:16
is there a nice and claen way to filter an object by keys instead of by vals
Gabe Johnson
@gabejohnson
Jul 07 2016 16:18
Lewis
@6ewis
Jul 07 2016 16:22
@gabejohnson nah. I'm talking about #filter
Gabe Johnson
@gabejohnson
Jul 07 2016 16:37
@6ewis i guess i don’t understand what you mean by filter an object
remove properties?
Barney Carroll
@barneycarroll
Jul 07 2016 16:37
I can say it in ramda vocab
Omit the pairs whose first item aren't in the supplied list
Gabe Johnson
@gabejohnson
Jul 07 2016 16:38
got it
Barney Carroll
@barneycarroll
Jul 07 2016 16:39
Er wait
That is omit
Gabe Johnson
@gabejohnson
Jul 07 2016 16:39
hahaha
Brad Compton (he/him)
@Bradcomp
Jul 07 2016 16:40
ha!
Lewis
@6ewis
Jul 07 2016 17:26
@Bradcomp omit here you go
gracias amigos
Brad Compton (he/him)
@Bradcomp
Jul 07 2016 17:48
@6ewis There's mapObjIndexed for that
Lewis
@6ewis
Jul 07 2016 17:49
@Bradcomp How did you know what I was going to ask...thanks!
Brad Compton (he/him)
@Bradcomp
Jul 07 2016 17:50
Lucky guess ;)
Emilio Srougo
@Emilios1995
Jul 07 2016 18:56
Hi everyone! can someone help me with this one?
http://goo.gl/QeQRBz
Emilio Srougo
@Emilios1995
Jul 07 2016 21:09
This the best I could come up with. http://goo.gl/4OM4Nn
I wonder if someone have a more elegant/point-free solution
Gabe Johnson
@gabejohnson
Jul 07 2016 21:22
@Emilios1995 can you put a problem statement in a comment?
you want to see which is new and which is an update?
Emilio Srougo
@Emilios1995
Jul 07 2016 21:27
@gabejohnson Exactly. And if it's an update, I need the id of the original (to delete it from the server) and the updated object (to save it). If it's new, then i'll just save it.
@gabejohnson So, updated would be an array of pairs consisting of the id (from the array_server) and the updated obj. and news just an array of new objects. My current solution doesn't fully achieves this :(
Gabe Johnson
@gabejohnson
Jul 07 2016 21:32
well if you just need the id of the updated and don’t care about the type
This message was deleted
Scott Sauyet
@CrossEye
Jul 07 2016 21:33
a very slight clean-up: http://goo.gl/90h6KS
nm @gabejohnson has a much better one.
Gabe Johnson
@gabejohnson
Jul 07 2016 21:37
@CrossEye i’m just lazy is all :wink:
Scott Sauyet
@CrossEye
Jul 07 2016 21:39
I'll blame the fact that I'm trying to do this on my mobile. :wink2:
Emilio Srougo
@Emilios1995
Jul 07 2016 21:39
@gabejohnson Sure, but I need both, the updated version, and the old's Id. (maybe as pairs?)
Because, again, I'll use the id to delete from the server and then upload the updated version.
(this is not a DB where a can just update records)
@CrossEye Thanks, but anyways I didn't present the problem well, as you can see above
Emilio Srougo
@Emilios1995
Jul 07 2016 21:52
Sorry about the confusion 😬 . This is the problem properly presented: http://goo.gl/v8PiaK
Gabe Johnson
@gabejohnson
Jul 07 2016 21:53
@CrossEye that’s hard-core
Emilio Srougo
@Emilios1995
Jul 07 2016 22:06
@gabejohnson Yes, we have an avid community! 😉 @CrossEye . Thanks!