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

Aaron Denney wnoise at ofb.net
Mon Nov 13 12:57:16 EST 2006


On 2006-11-13, roconnor at theorem.ca <roconnor at theorem.ca> wrote:
> On Mon, 13 Nov 2006, Bulat Ziganshin wrote:
>
>> i prefer name splitEithers. for me, unzipping is process of splitting
>> list of (a,b) values into the list of 'a' values and list of 'b'
>> values - just like unzipping in real life. this don't have anything common
>> with the algorithm of this function
>
> The concern I have with split is that almost all the other split functions 
> work by taking an ordered container and returning two containers where 
> everything in the first container preceeds everything in the second 
> container.  unzipEithers doesn't have this property.   However 
> unzipEithers is a process of splitting a list of Either a b values into 
> a list of 'a' values and a list of 'b' values, similar to the unzip 
> function.

Unzip is reversible though.  The order is preserved, and
(uncurry zip) . unzip = id = unzip . (uncurry zip)
There is no "zipEithers" that is any sort of reverse.

While I understand what is meant by unzipEithers, I think that I too
would prefer split, break, extract, partition, or similar.

If we think of lazy stream processing, it's a type of sorting fork or
railway switch.

Hmm.  (,) is the generic product, and Either is the generic coproduct.
counzip?

-- 
Aaron Denney
-><-



More information about the Libraries mailing list