Proposal: Add conspicuously missing Functor instances for tuples
alois.cochard at gmail.com
Tue Jan 19 15:24:29 UTC 2016
Agree for consistency, I can also see those instances as being useful in
some specific context, even if I agree with Andreas that in general they
should be discouraged (especially for newcomers).
On 19 January 2016 at 09:20, Herbert Valerio Riedel <hvriedel at gmail.com>
> On 2016-01-18 at 21:10:07 +0100, David Feuer wrote:
> > For some reason I really can't imagine, it seems the only tuple type
> > with a Functor instance is (,) a. I was astonished to find that
> > fmap (+1) (1,2,3)
> > doesn't work. Since this is *useful*, and there is *only one way to do
> > it*, I propose we add the following:
> > instance Functor ((,,) a b) where
> > fmap f (a,b,c) = (a,b,f c)
> > instance Functor ((,,,) a b c) where
> > fmap f (a,b,c,d) = (a,b,c,f d)
> > etc.
> As stated elsewhere in this thread already, there is the issue about
> consistency. Here's a relevant section from the Haskell 2010 report:
> > 6.1.4 Tuples
> > ...
> > However, every Haskell implementation must support tuples up to size
> > 15, together with the instances for Eq, Ord, Bounded, Read, and Show.
> IMO, we either have no `Functor` instances for tuples at all, or we have
> them for all tuples up to size 15. The current situations of having them
> defined only for 2-tuples is inconsistent.
> Libraries mailing list
> Libraries at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libraries