catch instance Foldable ((, ) a) (Was: What Haskell users are actively maintaining or deving software using ghc <8)

Zemyla zemyla at gmail.com
Fri May 29 14:34:28 UTC 2020


I am opposed to all the hate on Foldable ((,) a). For one thing, it's the
parent of the perfectly good Traversable ((,) a) instance. For another,
typeclasses should be defined for every type which has a valid and sensical
instance, so people don't run into "Why isn't this defined?" and having to
write orphan instances for it.

For another, it just feels like the majority of it is directed at "length
('a', 1)" returning 1 instead of 2. But does anyone expect "foldr (+) 0
('a', 1)" to return "'a'+1+0" as if that were even a thing? People don't
seem to have a problem with the Functor instance for ((,) a) only mapping
over the second value, and the Applicative and Monad instances treat the
first argument entirely differently from the second.

It's a failure of expectations more than anything else, and I really don't
think anyone beyond beginner level is routinely running into bugs because
they tried to use length or toList on a tuple.

On Fri, May 29, 2020, 09:10 Richard Eisenberg <rae at richarde.dev> wrote:

>
>
> > On May 29, 2020, at 4:47 AM, Ben Gamari <ben at smart-cactus.org> wrote:
> >>
> >> https://gitlab.haskell.org/ghc/ghc/issues/11796
> >>
> > Indeed. All we need is someone to implement. Admittedly, I don't have
> > much insight into how difficult this would be. Richard or Simon
> > would likely be more helpful in this regard.
>
> Implementation should be quite easy. The challenge is in the design. The
> design in the ticket looks plausible, but you would have to start by making
> a GHC proposal.
> >>
> >> Interesting idea. Or would it be better implemented in a type-checker
> >> plugin?
> >>
> > That would be another approach but I don't believe this is possible with
> > our current typechecker plugin mechanism..
>
> I agree with everything Ben said here. We look to plugins only after GHC
> has failed internally. Maybe that's not the best design, but it's what we
> have.
>
> Richard
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20200529/0464fe55/attachment.html>


More information about the Libraries mailing list