The GHC Steering Committee is considering accepting https://github.com/ghc-proposals/ghc-proposals/pull/425, a proposal to add new syntax allowing more explicit datatype and class declarations. For example, instead of writing
class Category cat where ...
we can now write (optionally!)
class Category @k (cat :: k -> k -> Type) where ...
Note the new @k
bit. This new feature is fully optional, but it will allow clarity in a number of declarations, and there are a few obscure scenarios where it allows us to make type definitions that were previously impossible to express.
Along with this primary change, the proposal cleans up a number of related facilities. These cleanups will encourage more readable code and will lead to better error messages. However, there are breaking changes. In light of recent worries about breaking changes, we want to reach out to the broader community seeking feedback before we accept this proposal.
The breaking changes can be seen at ghc-proposals/0000-decl-invis-binders.rst at decl-invis-binders ¡ serokell/ghc-proposals ¡ GitHub, which can be read without reading the rest of the proposal. There are 4 separate breakages, all of which only affect code that use relatively fancy type-level features.
- One will be delayed by three releases, as its fix is not backward compatible. Code that works today will continue to work for three more releases, but then it wouldnât. The fix will be available from the first release that implements the proposal, so an author can apply the fix at any time during the next three release cycles.
- One breakage is very obscure but has no migration path. If anyone has written code that triggers this, they would have to either use CPP or rather creative type shenanigans to keep their code compiling both before and after this change. Remember that the code is very obscure!
- Two breakages have backward-compatible mitigations (that also improve readability). Code that works today would stop working on the release the implements the proposal, but the fix can be applied, and code with the fix compiles for several GHCs (reaching back into the middle of the GHC 8 series).
All of the details, including examples, are linked above. Note that each breakage is optional. We donât have to do this, but we think the language will be better afterwards than before.
What does the community think here? The committee is broadly in favor. But would the breakage be too disruptive? If you think this would be problematic, it would be very helpful to us if you could point to a specific package (or better, module & line number!) that would be affected.
Even if we go forward at this point, once the change is applied, we will test against head.hackage and report back if that experience suggests we re-examine.