Re: [GHC] #974: Add unzipEithers, lefts, rights to Data.Either

On Fri, 15 Feb 2008, GHC wrote:
Comment (by igloo):
Having reread the thread, I think we are here:
We are agreed that we should add {{{ lefts :: [Either a b] -> [a] rights :: [Either a b] -> [b] }}} and that we should add a function with type {{{ [Either a b] -> ([a],[b]) }}} Possible names include {{{ splitEithers unzipEithers partitionEithers catEithers leftRights leftsAndRights boths demuxEithers }}} While choosing a name, we should bear in mind that we might want to define a function with type {{{ (a -> Either b c) -> [a] -> ([b],[c]) }}} at some point in the future.
I am reopening discussion of this trac. Here are mine (and some others) comments on the possible names: splitEithers - reject because the result of split should be such that the concatination of the resulting two lists should be (isomorphic) to the original list. unzipEithers - reject because unzip should have the same length as the original lists. Also unzipEithers suggests there is a zipEithers somewhere. catEithers - reject because this isn't a concatination. leftRights, leftAndRights, boths - reject because they are mnenomic enough. demux, demuxEithers - these are less popular options. demux is too general, but may make for an intersting class definition somewhere. partitionEithers - This is (I believe) the most popular (or least controversial) name. The output of our function has similar properties to the output of partition. The only objection possible objection is that partitionEithers perhaps should have type (a -> Either b c) -> [a] -> ([b],[c]), ie. partitonEithers should take a function as a parameter. The response to this objection by saying that the extra `Eithers' in the name fills the place of the predicate/function. Also the function of type (a -> Either b c) -> [a] -> ([b],[c]) is less widely used that the function we are trying to name in this trac. -- Russell O'Connor http://r6.ca/ ``All talk about `theft,''' the general counsel of the American Graphophone Company wrote, ``is the merest claptrap, for there exists no property in ideas musical, literary or artistic, except as defined by statute.''

Hi Russell On 15 Feb 2008, at 21:36, roconnor@theorem.ca wrote:
On Fri, 15 Feb 2008, GHC wrote:
Comment (by igloo):
Having reread the thread, I think we are here:
We are agreed that we should add {{{ lefts :: [Either a b] -> [a] rights :: [Either a b] -> [b] }}} and that we should add a function with type {{{ [Either a b] -> ([a],[b]) }}}
Any chance of left-factoring foldMap from the above? It's funny: what's important about the [] on the left is that it's Foldable; what's important about the [] on the right is that it's Alternative. What's both? More than one candidate, but [] is a runaway winner perhaps. Curious stuff. What if we had left :: Either a b -> Maybe a right :: Either a b -> Maybe b may :: Alternative f => Maybe a -> f a and suitable other bits and pieces? I fear that foldMap ((may . left) &&& (may . right)) is a longer name than you were hoping for, but it says what it does on the tin. Cheers Conor

On Fri, 15 Feb 2008, roconnor@theorem.ca wrote:
partitionEithers - This is (I believe) the most popular (or least controversial) name. The output of our function has similar properties to the output of partition. The only objection possible objection is that partitionEithers perhaps should have type (a -> Either b c) -> [a] -> ([b],[c]), ie. partitonEithers should take a function as a parameter. The response to this objection by saying that the extra `Eithers' in the name fills the place of the predicate/function. Also the function of type (a -> Either b c) -> [a] -> ([b],[c]) is less widely used that the function we are trying to name in this trac.
If there are no further comments before March 7th, We shall declare that parititonEithers, lefts, and rights, shall be added to Data.Eithers. :) -- Russell O'Connor http://r6.ca/ ``All talk about `theft,''' the general counsel of the American Graphophone Company wrote, ``is the merest claptrap, for there exists no property in ideas musical, literary or artistic, except as defined by statute.''

roconnor@theorem.ca wrote:
If there are no further comments before March 7th, We shall declare that parititonEithers, lefts, and rights, shall be added to Data.Eithers.
Would prefer "partitionEithers". -- Ashley Yakeley
participants (3)
-
Ashley Yakeley
-
Conor McBride
-
roconnor@theorem.ca