Warning about certain instances (Was: Add conspicuously missing Functor instances for tuples)

Henning Thielemann lemming at henning-thielemann.de
Wed Feb 17 10:30:17 UTC 2016


On Mon, 18 Jan 2016, Eric Seidel wrote:

> We might be able to make this work as a type-checker plugin (which would 
> be quite nice at least for experimentation). I don't recall off the top 
> of my head if the constraint solver calls plugins before or after it 
> tries to discharge the constraints on its own, but if plugins get access 
> to constraints first we could write one that simply marks undesired 
> instances as insoluble.

Nice to see that you have concrete suggestions how to implement such a 
warning. Once I proposed an extension for forbidding certain instances:
   https://ghc.haskell.org/trac/ghc/ticket/7775

I was forwarded to the "instance chain" proposal that would solve my 
problem:
   https://ghc.haskell.org/trac/ghc/ticket/9334

This ticket also contains a solution that requires only existing 
extensions. However this solution does not allow to only warn about a 
problematic instance or to prevent the use of such an instance only 
locally.

A proper solution would allow to define a set of forbidden instances and 
import that in other packages, but does not affect packages later in the 
import chain. A way for explicit import of instances was discussed every 
now and then. This might also provide a way to get rid of specific 
instances.


However, every solution seems to be a long way to go. Eventually, it looks 
wrong to me to add security holes first and then start to fix them, or 
defer that for an indefinite time.


Btw. I see that the problem was already discussed on Reddit:
https://www.reddit.com/r/haskell/comments/3qcg2d/proposal_forbidden_instances/


More information about the Libraries mailing list