-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make functions correspond more closely to Data.Map behavior #50
Conversation
This is a breaking change. The more "monoidal" behaviors that this reverts could eventuallly be re-added as a separate module that more thoroughly and systematically applies the monoid/semigroup operations. The goal of Data.Map.Monoidal is to be as similar to Data.Map as possible except for the Monoid/Semigroup instance that it replaces.
e27bc2a
to
021685c
Compare
Some ideas worth considering before we go all out on this revert. @bgamari and @ali-abrar and I are already in agreement that
At the very least we need to have some clear documentation on both of these fronts:
|
The clear direction (at least in my mind) is that this library is just Data.Map, etc. with different instances. We should be able to auto-generate it in some way, implementing everything in terms of coerce, which would be good, since then perhaps we'd get Data.Map.Merge etc. and there would be no question as to how any given thing worked: it works in exactly the same way Data.Map works, except that it corrects a historical accident and has the Semigroup and Monoid instances that Data.Map ought to have had all along. The only really confusing thing is the name "Monoidal" possibly suggesting more than what was/is the case. There's nothing especially monoidal about these maps, it's just that they have a more general Monoid instance that uses a Semigroup on the values. The Maybe data type for example isn't called MonoidalMaybe, and really has very little to do with monoids in general, it just has an instance of this sort. I liked the name "AppendMap" in our other library prior to this one a bit more, but even that is insufficiently subtle. However, I do think there is some need for additional libraries which more aggressively use a monoid structure on the values to emulate natural operations on functions k -> m when m is a monoid. That's just not what this library is (at least not versions 0.1 through 0.4), and changing it in a piecemeal way has broken a bunch of stuff and made an impossible upgrade situation where moving to 0.5 causes probably-incorrect changes to behaviour that nobody will be warned about (which has sadly affected reflex-dom for a couple versions since it required one of the other, more subtle changes to this library that landed in 0.5, due to the Data.Align split). Now, we could filter certain functions out of this library relative to Data.Map, and at least there would be an upgrade path (though a possibly somewhat annoying one), but the confusion about them confuses me. Would we really advocate for the removal of insert and fromList from containers? I think Elliot perhaps would, but I'm not so sure about everyone else. These functions seem fine to me, so long as they're used conscientiously. Yes, they're not injective (though neither are insertWith (<>) etc.), and yes, insertWith and fromListWith are preferable when you have a meaningful way of combining the elements. But I don't know about just getting rid of them entirely. There are times when insert and fromList ought not to be used, but I don't know if I'd really agree that's "all of the time". We can think more about that, but right now I just want to put things back to where they were roughly with 0.4 (except with the other new additions intact) and deprecate 0.5 of monoidal-containers and all the affected versions of our other libraries before more damage is done by the unexpected semantic changes. Then it won't be an emergency, and we can think more calmly about whether we want to drop certain functions and push that through. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for taking this on!
@cgibbard You're right that I would advocate for removing |
Perhaps a better name than |
This causes another difference: the relationship between some functions changes. For instance, |
Right. Which is why I think documenting the scope and purpose of this library (as in #51) is paramount. |
This is a breaking change. The more "monoidal" behaviors that this
reverts could eventually be re-added as a separate module that more
thoroughly and systematically applies the monoid/semigroup operations.
The goal of Data.Map.Monoidal is to be as similar to Data.Map as
possible except for the Monoid/Semigroup instance that it replaces.
Thanks to @cgibbard and @bgamari for helping clarify this goal.