leftToMaybe/rightToMaybe

David Luposchainsky dluposchainsky at googlemail.com
Thu Aug 8 12:52:20 CEST 2013


On 2013-08-07 19:13, Erik Hesselink wrote:
>> mapEither :: (l -> l') -> (r -> r') -> Either l r -> Either l' r'
>> mapEither fl fr = either (Left . fl) (Right . fr)
> 
> This function is hidden in Control.Arrow as (+++).

I didn't know about those functions, and it seems everything I wanted is
in there somewhere. However, I'm not sure what to think of
Control.Arrow, I've always (ab)used it as an extended Data.Tuple, and as
of today probably for its Either API functions.

The thing is of course that Arrows aren't meant to be *just* that. Maybe
there should at least be a highlighted section in Data.Either/Data.Tuple
telling the user about the functionality provided in Control.Arrow? Most
of the functions proposed here seem redundant, apart from the fact that
they're arguably not in the right place. (A specialized re-export might
be worth considering too, although I'm not sure whether I'd personally
want that.)

David





More information about the Libraries mailing list