Exponentially increasing compilation w/ Higher-Kinded Data under 9.8.1
See also:
* #24984
## Summary
GHC 9.8.1 takes increasingly longer (and uses radically more memory) to compile a module as fields are added to a data type; the same did not occur with GHC 9.6.
## Steps to reproduce
The repo at https://github.com/m4dc4p/ghc98-bug can demonstrate the issue. You can just run `cabal build` to try it.
The file `AAAX.hs` contains the `HKDType` data type. As you uncomment fields, the compilation times (`cabal build`) take longer and longer.
For example, on my M2, with GHC 9.8, I get these timings & peak memory usage:
* 1 field - 2.5s, 198MB peak
* 2 fields - 7s, 1.0GB peak
* 3 fields - 26.8s, 4.6GB peak
* 4 fields - 82.9s, 14.5GB peak
Note that with -O0, there is no problem - compilation time does not increase. Also, removing the standalone `Eq` instance also causes the problem to go away (but, of course, I want that instance).
Under GHC 9.6, with -O1, compilation times do not increase either (even up to 10 fields on the data type).
I found this on MacOS 14.2.1, using an M2 chip.
(Note I also reported this as a bug against the Barbies library - https://github.com/jcpetruzza/barbies/issues/51)
issue