-
Notifications
You must be signed in to change notification settings - Fork 66
Changing a private type to a type alias shouldn't be a major change #289
Comments
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it! Here is what to expect next, and if anyone wants to comment, keep these things in mind. |
A counter argument: Clients of version A of your package, where the type was hidden, may rely on some invariants that the type guarantees, but which cannot anymore be taken for granted when using version B of your package. Because even if version B of your package still preserves these invariants, some completely unrelated package could mess them up. That loss of the invariant seems a rather radical API change. A more concrete example: Say your package provides this type |
But then again I myself can decide that the invariant shouldn't be there and release a patch version that breaks the invariant without any issues. Furthermore, the code that actually translates Finally, if my code enforces invariants about the content of its types, than surely changing the type representation from what I control to something I don't would be a pretty bad idea from that point of view. What I'm trying to say is that the way elm package enforces semver is about code breaking in the "wont compile" sense. You are still free to break other people's code in the "it's buggy now" sense. The case you present is firmly in the second category, which seems impossible to prevent anyway. |
Is "the condition for semver in Elm is exactly and only about 'still compiles'" documented somewhere? And I do think that the case I presented is not the same as "I introduced a bug in a patch release". Because that would be an issue just between me and you. But opening up the type brings a third person into the picture that can introduce bugs into my code. My point is: When I hypothetically started to use your package version A, and looked at the API, I saw that the type But yes, one can take the "it's only about whether stuff still compiles" standpoint. (Aside: What if one said "it's about whether stuff that previously compiled still compiles but also stuff that previously did not compile does not suddenly start compiling"? Would that latter condition be compatible with current semver criteria for Elm? It seems a useful perspective in its own right, and it would explain why changing a private type to a non-private type requires a major version bump.) |
If I publish this module:
Then I change it to:
elm package will indicate that this is a MAJOR change. However, this doesn't seem right as none of the code using the package will break as the constructor wasn't exposed and so all of the values must have been treated as a black box until now.
Aside about how this happened in the real world
I had a type called
Curve
in elm-visualization which a class of functions could consume to compute smooth lines between. The library provides a few of those, but I always wanted the user to be able to use their own. These could be used in several different scenarios, so I wasn't sure if the type would need to have cases for these scenarios or if all the scenarios could be implemented in a generic way. So I decided to not expose the constructors and punt on the decision until I had more time to investigate the problem. Now that it has become clear that indeed all of the scenarios can be represented as a simple list of coordinates, I would like to relax this constraint and simply allow these functions to operate on the laxer type.The text was updated successfully, but these errors were encountered: