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

roconnor at theorem.ca roconnor at theorem.ca
Fri Feb 15 16:36:25 EST 2008


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.''


More information about the Libraries mailing list