Proposal: Remove Semigroup and Monoid instances for Data.Map, Data.IntMap, Data.HashMap

Chris Wong lambda.fairy at gmail.com
Tue Feb 13 19:51:16 UTC 2018


Hi David,

On Feb 14, 2018 08:34, "David Feuer" <david.feuer at gmail.com> wrote:

Alternatives:

1. Remove the instances but don't add the new ones. I fear this may
lead others to write their own orphan instances, which may not even
all do the same thing.

2. Write separate modules with newtype-wrapped versions of the data
structures implementing the desired instances. Unfortunately, this
would be annoying to maintain, and also annoying to use--packages
using the unwrapped and wrapped versions will use different types.
Manually wrapping and unwrapping to make the different types work with
each other will introduce lots of potential for mistakes and
confusion.


A third alternative is to "poison" the instances by placing TypeError in
their constraints. This would prevent users from writing orphan instances,
as they would overlap with the poisoned ones.

On other Haskell implementations (if we still support them), we can use a
private class with no instances for this purpose.

See
https://hackage.haskell.org/package/base-4.10.1.0/docs/GHC-TypeLits.html#t:TypeError

Chris


Discussion period: three weeks.

[*] http://teh.id.au/posts/2017/03/03/map-merge/index.html
_______________________________________________
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/20180214/5d8b04b0/attachment.html>


More information about the Libraries mailing list