You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While concatMap is a descriptive name, it has a strange academic feel to it that confuses a lot people. We should find a nicer name (no doubt there is something clearer in the underscore.js/mongo world). emit, extract or something of the sort (I don't have a really good one, unfortunately)
To clarify what I meant, I agree that we need concatMap, I also think that we should keep it because it's awesome and not because we just need it, and I think we should make it available to users because it's actually very useful in dealing with arrays. I just think we should rename the function itself to something more palatable. Mongo people call (a much less powerful but roughly equivalent function) unwind which is an ok name, though I'm not too thrilled about it.
I think I've seen that used in Mongo and I had to look up what it means as unwind didn't tell me anything. The only other reference to unwind in APIs is in Cascading.
I'm also thinking that we already have union for concatenating 2 sequences, so maybe this is a unionMap (?)
Minor changes are over the shoulder, major changes are being reviewed by
individual reviewers (to my understanding). You can also always see the
history of YAML doc changes in GH.
Also, just out of curiosity, are changes to the docs going through ccollab
at this point?
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/334#issuecomment-15740819
.
Moving to 1.8, as this will become important for word counting example in map/reduce. Can we think of a better name for concatMap? Pinging @neumino, @mglukhovsky -- do you think concatMap is a good name? Can you think of anything better?
Did we have users complaining about concatMap being scary?
I think it's fine. With our current API, I would more expect a syntax like that
sequence.map().concat()
I don't like unwind -- in the sense that I have no idea what it can do (with just the name) flatMap is fine, but I somehow prefer concatMap. To "flatten" is less common than "concat" (at least that's how I feel as a non native English speaker)
Nobody (that I remember) complained about concatMap, but I don't think people use the function often yet. This name seems confusing to me personally. In general, if we can come up with a good, descriptive single word name for this function, I'd like to do that. If we end up using a concatenation of two words (e.g. flatMap), I think we might as well use concatMap.
To be clear, I don't think changing the name is a matter of adoption. Here is how I think about this. If we do our job well (and we have to assume we will, because otherwise the whole discussion becomes moot), in a year or two everyone will be using RethinkDB, and they'll be stuck with it for ten or fifteen years or more. Do we really want concatMap to be a part of that API? It seems like the worst named function in ReQL to me right now, and I'd like to think of something better if possible.
This operation should not be called flatten. Flattening is an operation on trees (or recursive lists of lists). Here's an example from the Underscore documentation:
Here's a summary of most of the proposals made here. I might have missed some proposals and/or pros/cons. Please let me know if anything important is missing.
Stick with concatMap
+ compatibility
+ "concat" isn't actually such a bad name probably
I'd leave concatMap as it is, since the name is pretty standard, and add a recursive flatten term. I think if the major use case for this term moves to another term, (i.e. everyone takes all their array flattening business over to the flatten store), then concatMap is free to have a scary name since it'll only be used in odd circumstances.
I don't see a lot of benefit to trying to make the name less general so it's easier to explain. It does exactly what's on the tin, it maps and concatenates.
@deontologician That sounds reasonable.
So we could solve #3435 and probably some other use cases by introducing flatten. I guess it would be recursive by default, but we could add an opt arg to turn that off.
I don't object strongly to union_map, but it's worth noting that while currently union concatenates streams, we've never explicitly promised that, and it would be more efficient in a lot of cases to intersperse elements from the different streams, so I could imagine a future in which union means "give me the elements from all of these streams in whatever way is most efficient" rather than "concatenate these streams".
If we decide to commit to the current concatenation semantics for union, then union_map seems fine to me, and might be more obvious to people.
@mlucy that's a good point. I think especially with changefeeds we don't want to guarantee any particular ordering for union.
I personally am tempted to close this and stick with concatMap, since none of the discussed alternatives seem to be without caveats.
Does anyone still believe strongly that we should rename concatMap?
FWIW: I spent an hour today looking for the functionality that concatMap provides. However, coming from the MongoDB world, I was more familiar with the term 'unwind'. I wouldn't advocate changing the name at this point, but including the term "unwind" or "flatten" in the docs would help recovering MongoDB devs identify/google the term.
In my case, I'm looking to map reduce on arrays of objects, which is often how unwind is used with Mongo. Might be helpful to include that use case some where in the docs, if it isn't already there.
Thanks for the feedback @briant5q @chipotle Do you think we could sneak those terms into the concat_map documentation? We could say something like
"This operation is also known as "flattening" or "unwinding" the sequence."
Activity
jdoliner commentedon Feb 14, 2013
Underscore has considered and refused to implement concatMap. They instead have a syntax I'm not too crazy about:
In rethinkdb this would be:
I can't find a mongo syntax for concatMap maybe I'm just missing it.
Either way we need concat map because other crucial features desugar to it but we don't need to expose it to users if the name is too daunting.
coffeemug commentedon Feb 14, 2013
To clarify what I meant, I agree that we need
concatMap, I also think that we should keep it because it's awesome and not because we just need it, and I think we should make it available to users because it's actually very useful in dealing with arrays. I just think we should rename the function itself to something more palatable. Mongo people call (a much less powerful but roughly equivalent function)unwindwhich is an ok name, though I'm not too thrilled about it.jdoliner commentedon Feb 14, 2013
What about
flatMaporflattenMap. That might be a bit more descriptive.coffeemug commentedon Feb 14, 2013
@al3xandru -- name thoughts?
al3xandru commentedon Feb 14, 2013
flatMap(this also seems to be a function available in Scala)
coffeemug commentedon Feb 14, 2013
Upon reflection, I actually really like
unwind.al3xandru commentedon Feb 14, 2013
I think I've seen that used in Mongo and I had to look up what it means as
unwinddidn't tell me anything. The only other reference tounwindin APIs is in Cascading.I'm also thinking that we already have
unionfor concatenating 2 sequences, so maybe this is aunionMap(?)al3xandru commentedon Apr 1, 2013
FWIW, I recently changed the API docs for
concat_mapto:Run it by a couple of people and they found it very clear.
mlucy commentedon Apr 1, 2013
That actually seems mildly confusing to me. In most languages
flattenis a recursive operation:Whereas
concat_mapjust concatenates the returned arrays rather than recursing into them and flattening all the way down.mlucy commentedon Apr 1, 2013
Also, just out of curiosity, are changes to the docs going through ccollab at this point?
mglukhovsky commentedon Apr 1, 2013
Minor changes are over the shoulder, major changes are being reviewed by
individual reviewers (to my understanding). You can also always see the
history of YAML doc changes in GH.
On Mon, Apr 1, 2013 at 3:16 PM, Michael Lucy [email protected]:
al3xandru commentedon Apr 1, 2013
@mlucy since @coffeemug suggested using ccollab for all doc changes, all my changes are following the process.
coffeemug commentedon Jun 30, 2013
Moving to 1.8, as this will become important for word counting example in map/reduce. Can we think of a better name for
concatMap? Pinging @neumino, @mglukhovsky -- do you thinkconcatMapis a good name? Can you think of anything better?neumino commentedon Jun 30, 2013
Did we have users complaining about
concatMapbeing scary?I think it's fine. With our current API, I would more expect a syntax like that
I don't like
unwind-- in the sense that I have no idea what it can do (with just the name)flatMapis fine, but I somehow preferconcatMap. To "flatten" is less common than "concat" (at least that's how I feel as a non native English speaker)coffeemug commentedon Jul 1, 2013
Nobody (that I remember) complained about
concatMap, but I don't think people use the function often yet. This name seems confusing to me personally. In general, if we can come up with a good, descriptive single word name for this function, I'd like to do that. If we end up using a concatenation of two words (e.g.flatMap), I think we might as well useconcatMap.To be clear, I don't think changing the name is a matter of adoption. Here is how I think about this. If we do our job well (and we have to assume we will, because otherwise the whole discussion becomes moot), in a year or two everyone will be using RethinkDB, and they'll be stuck with it for ten or fifteen years or more. Do we really want
concatMapto be a part of that API? It seems like the worst named function in ReQL to me right now, and I'd like to think of something better if possible.29 remaining items
AtnNn commentedon Dec 13, 2014
This operation should not be called
flatten. Flattening is an operation on trees (or recursive lists of lists). Here's an example from the Underscore documentation:I personally like the names
concatandconcatMapdanielmewes commentedon Dec 13, 2014
Here's a summary of most of the proposals made here. I might have missed some proposals and/or pros/cons. Please let me know if anything important is missing.
Stick with
concatMapflatMap()flattenMap()concatMapfor someflattenis associated with recursively nested structures in some languages RenameconcatMapto something less scary #334 (comment)map(... {multi: true})concatMapto something less scary #334 (comment)unwind()(orunwindMap?)emit()concatMapto something less scary #334 (comment) and around)unionMap()union(unless there's a difference we haven't discussed here)Make it
map().concat()catcommandconcatMap()addon arrays RenameconcatMapto something less scary #334 (comment)concatMapto something less scary #334 (comment)Make it
map().flatten()flattenMap()concatMapto something less scary #334 (comment)danielmewes commentedon Dec 13, 2014
We hadn't really discussed
unionMapvery much. Any additional thoughts on that?deontologician commentedon Dec 13, 2014
I'd leave
concatMapas it is, since the name is pretty standard, and add a recursiveflattenterm. I think if the major use case for this term moves to another term, (i.e. everyone takes all their array flattening business over to theflattenstore), thenconcatMapis free to have a scary name since it'll only be used in odd circumstances.I don't see a lot of benefit to trying to make the name less general so it's easier to explain. It does exactly what's on the tin, it maps and concatenates.
danielmewes commentedon Dec 13, 2014
@deontologician That sounds reasonable.
So we could solve #3435 and probably some other use cases by introducing
flatten. I guess it would be recursive by default, but we could add an opt arg to turn that off.thelinuxlich commentedon Dec 13, 2014
+1 for unionMap, for me it instantly made me understand what it does
mlucy commentedon Jan 15, 2015
I don't object strongly to
union_map, but it's worth noting that while currentlyunionconcatenates streams, we've never explicitly promised that, and it would be more efficient in a lot of cases to intersperse elements from the different streams, so I could imagine a future in whichunionmeans "give me the elements from all of these streams in whatever way is most efficient" rather than "concatenate these streams".If we decide to commit to the current concatenation semantics for
union, thenunion_mapseems fine to me, and might be more obvious to people.danielmewes commentedon Jan 20, 2015
@mlucy that's a good point. I think especially with changefeeds we don't want to guarantee any particular ordering for
union.I personally am tempted to close this and stick with
concatMap, since none of the discussed alternatives seem to be without caveats.Does anyone still believe strongly that we should rename
concatMap?coffeemug commentedon Jan 21, 2015
👍 for closing
danielmewes commentedon Jan 23, 2015
I interpret the lack of protest as a no.
Of course we can always re-open it later.
briant5q commentedon May 15, 2015
FWIW: I spent an hour today looking for the functionality that concatMap provides. However, coming from the MongoDB world, I was more familiar with the term 'unwind'. I wouldn't advocate changing the name at this point, but including the term "unwind" or "flatten" in the docs would help recovering MongoDB devs identify/google the term.
In my case, I'm looking to map reduce on arrays of objects, which is often how unwind is used with Mongo. Might be helpful to include that use case some where in the docs, if it isn't already there.
danielmewes commentedon May 15, 2015
Thanks for the feedback @briant5q
@chipotle Do you think we could sneak those terms into the concat_map documentation? We could say something like
"This operation is also known as "flattening" or "unwinding" the sequence."