Add missing Monad/Traversable instances to tuples
Matthew Pickering
matthewtpickering at gmail.com
Tue Apr 2 07:40:12 UTC 2019
For all the reasons in the old thread -1 from me.
To repeat the main reason: this change introduces bugs into programs
which are very hard to detect.
The main benefit I can see is the small amount of convenience for a
few people, as the expense of potential bugs for any user who returns
multiple values from a function.
If you want to traverse or fold a contain with one element and two
additional data parameters then it is simple to define a newtype for
this purpose which can be `coerce`ed to for no cost.
newtype Data3 a b c = Data3 (a, b, c)
The argument about "adding all unambiguous instances" is not well
motivated or adhered to, for example, there is no Num instance for
functions.
Cheers,
Matt
On Tue, Apr 2, 2019 at 5:29 AM Fumiaki Kinoshita <fumiexcel at gmail.com> wrote:
>
> I submitted https://gitlab.haskell.org/ghc/ghc/merge_requests/644 but it might be still controversial. I'd like to get more opinions again.
>
> Here's the list of proposed instances:
>
> Foldable ((,,) a b)
> Foldable ((,,,) a b c)
> Traversable ((,,) a b)
> Traversable ((,,,) a b c)
> Functor ((,,) a b)
> (Monoid a, Monoid b) => Applicative ((,,) a b)
> (Monoid a, Monoid b) => Monad ((,,) a b)
> Functor ((,,,) a b c)
> (Monoid a, Monoid b, Monoid c) => Applicative ((,,,) a b c)
> (Monoid a, Monoid b, Monoid c) => Monad ((,,,) a b c)
>
> The absence of Traversable instances for tuples feels quite inconsistent given that there are Bitraversable instances already.
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
More information about the Libraries
mailing list