Proposal: Add &&& and *** to Data.Tuple
Josef Svenningsson
josef.svenningsson at gmail.com
Wed Sep 19 09:51:48 EDT 2007
On 9/18/07, Benjamin Franksen <benjamin.franksen at bessy.de> wrote:
> Twan van Laarhoven wrote:
> > Other functions for which Arrow is often unnecessarily used are first
> > and second
> > > first :: (a -> b) -> (a,c) -> (b,c)
> > > first f (x, y) = (f x, y)
> > > second :: (a -> b) -> (c,a) -> (c,b)
> > > second f (x, y) = (x, f y)
> >
> > I think these should be added as well. I don't really like these names,
> > but they are the names from Control.Arrow. The problem is that 'fst' and
> > 'first' are essentially the same, but they do different things. Maybe
> > 'mapFst' or 'updateFst' is a better name.
>
> 'onFst' and 'onSnd' look nice to me:
>
> onFst (+1) (1,'a') ==> (2,'a')
>
I omitted first and second from my proposal exactly because I didn't
like the names. But onFst and onSnd sounds really nice. I'd be willing
to include them in the patch if there is a general agreement about it.
Cheers,
Josef
More information about the Libraries
mailing list