catch instance Foldable ((, ) a) (Was: What Haskell users are actively maintaining or deving software using ghc <8)

Henning Thielemann lemming at henning-thielemann.de
Thu May 28 17:06:51 UTC 2020


On Thu, 28 May 2020, Ben Gamari wrote:

> Henning Thielemann <lemming at henning-thielemann.de> writes:
>
>> 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.

https://gitlab.haskell.org/ghc/ghc/issues/11796

> * 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

Interesting idea. Or would it be better implemented in a type-checker 
plugin?

> * Using GHC's HIE output to implement a linter which would identify
>   above-mentioned dictionaries.


More information about the Libraries mailing list