eclipse-archived / ceylon

The Ceylon compiler, language module, and command line tools
http://ceylon-lang.org
Apache License 2.0
399 stars 62 forks source link

Combine is actually a map restricted to two lists #5183

Closed CeylonMigrationBot closed 8 years ago

CeylonMigrationBot commented 11 years ago

[@FroMage] combine is a special-case map for two lists. But it's still map. I think we can't write down the proper signature for map with N lists, which is why we have map + combine, but we can't be giving each of those a name out of nowhere. I know it sounds like defeat to rename combine to map2 but at least the name will be true and intuitive for everyone who knows map.

[Migrated from ceylon/ceylon.language#305] [Closed at 2013-11-05 21:44:56]

CeylonMigrationBot commented 11 years ago

[@quintesse] Totally agree. I already strongly dislike our collect and select synonyms for filter and map (I had to look them up again to see what they actually do), instead of the uglier but much more likely to be remembered correctly seqfilter and seqmap (or sequenceFilter and sequenceMap).

CeylonMigrationBot commented 11 years ago

[@gavinking] @FroMage I think you're right. How about bimap()?

CeylonMigrationBot commented 11 years ago

[@gavinking] @quintesse OTOH, I don't think you're right.

CeylonMigrationBot commented 11 years ago

[@quintesse] @gavinking I know you don't, but it's one of the things I positively hate in our current language module. It sucks to completely change the name of some very well known functions when the only thing they do basically is filter().sequence and map().sequence.

CeylonMigrationBot commented 11 years ago

[@FroMage] bimap is not good wrt completion, if someone expects map to be completed and sees map2 he may discover it, but not if it's called bimap.

I sorta agree with @quintesse on the less than ideal names for collect and select, because they are not easy to discover and mean nothing unless you already know them. I suppose that if there's a good see annotation on filter and map that point to them it may be better, but my preference would be filterSequential and mapSequential or some other thing that start with what people are going to look for. I think it is however easier to discover collect and select from an Iterable since you already know what class to look at and its documentation explains the difference. For toplevels such as combine this isn't true.

CeylonMigrationBot commented 11 years ago

[@FroMage] Do we agree on map2 or does this slip to 1.0?

CeylonMigrationBot commented 11 years ago

[@gavinking] Slips.

CeylonMigrationBot commented 10 years ago

[@gavinking] In fact, I think we should replace today's combine() with a function that accepts a stream of tuples and a stream of values, and produces a stream of extended tuples. We'll also need a way to get hold of an infinite stream of empty tuples.

So you would be able to write:

combine(xs, combine(ys, empties)).map(unflatten(fun));

Or perhaps instead of combine(ys, empties), we could use singletons(ys) to get a stream of singleton tuples.

CeylonMigrationBot commented 10 years ago

[@gavinking] combine() is now redefined as suggested, in terms of zip(). Now zip() itself fills the role that combine() used to fill.