To follow up with this, here are the changes we would make if we went with the approach above described by Harry:
- drop the
SemigroupandMonoidinstance forData.Map - define a newtype in
Data.MapcalledSemigroupMap. Its name makes it more obvious why it exists. ItsSemigroupinstance would be unbiased. It would have all the type class instances ofData.Map. However, it does not have any of the API ofData.Map(e.g.lookup, etc.). Thus, you would only use it when you needData.Mapto have aSemigroupinstance.
This comes with the following advantages
- Those who do rely on the left-bias nature of the current
Mapwill not experience a “silent” change. Rather, they will be forced to update their code. In situations where they are using this behavior, they will have to coerce theMap k vtoMap k (First v)and then wrap it in theSemigroupMapnewtype to get the same behavior. - Those who want the flexibility of the unbiased
Semigroupinstance can have it now rather than later. - We don’t have two
Maptypes that may confuse beginners or make it harder to import the correct function. - In
v0.15.0, I believe we would deprecate theSemigroupMapnewtype and add the unbiasedSemigroupandMonoidinstance back toData.Mapwith aWarnthat says something like “Instance differs from the instance defined in PS releases <= 0.13.x.” Inv0.16.0, we would remove theSemigroupMapnewtype and remove theWarnconstraint on theSemigroupinstance. - Those who jump two major releases would be notified of the change via the
Warnconstraint. Those who jump three major releases would not be notified, but that is likely very rare.