instance {Semigroup, Monoid} (Bag a) ?
Sebastian Graf
sgraf1337 at gmail.com
Wed Apr 14 19:10:57 UTC 2021
Hi Richard,
I've been guilty of slipping in similar instances myself. In fact, I like
OrdList better than Bag precisely because it has more instances and thus a
far better interface.
Not being able to see whether mempty denotes a Bag should be as simple as a
mouse hover with HLS set up.
So a +99 from me.
Cheers,
Sebastian
Am Mi., 14. Apr. 2021 um 20:28 Uhr schrieb Richard Eisenberg <
rae at richarde.dev>:
> Hi devs,
>
> In the work on simplifying the error-message infrastructure (heavy lifting
> by Alfredo, in cc), I've been tempted (twice!) to add
>
> > instance Semigroup (Bag a) where
> > (<>) = unionBags
> >
> > instance Monoid (Bag a) where
> > mempty = emptyBag
>
> to GHC.Data.Bag.
>
> The downside to writing these is that users might be tempted to write e.g.
> mempty instead of emptyBag, while the latter gives more information to
> readers and induces less manual type inference (to a human reader). The
> upside is that it means Bags work well with Monoid-oriented functions, like
> foldMap.
>
> I favor adding them, and slipped them into !5509 (a big commit with lots
> of other stuff). Alfredo rightly wondered whether this decision deserved
> more scrutiny, and so I'm asking the question here.
>
> What do we think?
>
> Thanks,
> Richard
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20210414/a1ea4429/attachment.html>
More information about the ghc-devs
mailing list