
Henning Thielemann
On Wed, 27 May 2020, Joseph C. Sible wrote:
On Wed, May 27, 2020 at 11:09 AM Henning Thielemann
wrote: I use 7.4.2 regularly. I like to avoid upgrading to 7.10 and above because I do not want to run into accidental bugs based on "maximum (a,b)".
IMO, avoiding "instance Foldable ((,) a)" isn't really a good reason to not upgrade. You're giving up a lot of bug fixes and other improvements just to avoid accidentally writing code that a linter will easily catch.
I am not giving up anything, because I test my code against both 7.4.2 AND newer GHC versions.
What linter can easily catch "instance Foldable ((,) a)"?
GHC cannot warn about it, so far.
Another solution would be to separate 'base' from GHC. I could then work with a patched 'base' with forbidden "instance Foldable ((,) a)".
For what it's worth, I suspect there are a few solutions to the problem of disallowing use of particular instances which may be close-at-hand: * Providing a compiler flag or pragma to "poison" an instance, locally preventing the compiler from using it as evidence; this would require a GHC proposal and may not be entirely trivial to implement, but it's certainly feasible. * Providing a GHC source plugin that would look for dictionaries of type (e.g.) Foldable ((,) a) in the desugared Core of a module and report them as errors * Using GHC's HIE output to implement a linter which would identify above-mentioned dictionaries. Cheers, - Ben