GHC2021 to GHC2024 - Tips about gotchas?

Thanks to everyone for the advice, and to @rae and his former colleagues at Tweag for that video. Stack’s code is now moved on to LANGUAGE GHC2024, without making use of NoMonoLocalBinds. Thanks also to the HLS project; HLS made the step of removing NoMonoLocalBinds far less painful than I had been anticipating.

Removing NoMonoLocalBinds and adding type signatures had the positive side effects of (a) Stack’s own code becomes more expressive (at least, to me) and (b) my realising that some local binds were more polymorphic than they needed to be (and, so, I could tell the compiler that).

My steps were, for each affected module:

  1. Toggle off LANGUAGE NoMonoLocalBinds. HLS used red ink to show me the areas of the code where the problems lay.
  2. Toggle on LANGUAGE NoMonoLocalBinds. Use HLS to hunt down in those general areas local bindings with polymorphic type signatures, and then add those signatures expressly to the code. In most cases, the hunt was straightforward. In only one case (out of 14) it was not.
  3. Consider whether the polymorphic type signatures needed to be as general as they then were.
  4. Consider whether, for the remaining polymorphic type signatures, whether the type variables picked by HLS/GHC output (in step 2) had the most expressive names in the context.
4 Likes