darcs patch: Adding isLeft, isRight, fromLeft, fromRight,
splitEithers
roconnor at theorem.ca
roconnor at theorem.ca
Tue Oct 31 07:17:09 EST 2006
On Tue, 31 Oct 2006, Bulat Ziganshin wrote:
>> It'd be nice to have the following, too:
>
>> lefts :: [Either a b] -> [a]
>> lefts = fst . splitEithers
>> rights :: [Either a b] -> [b]
>> rights = snd . splitEithers
>
> i think that this may be faster:
>
> lefts = filter isLeft
> rights = filter isRight
filter isLeft produces the wrong type.
I believe the correct definition is:
lefts x = [a | (Left a) <- x]
rights x = [a | (Right a) <- x]
--
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