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

Ben Gamari ben at smart-cactus.org
Fri May 29 03:47:24 UTC 2020


Henning Thielemann <lemming at henning-thielemann.de> writes:

> 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
>
Indeed. All we need is someone to implement. Admittedly, I don't have
much insight into how difficult this would be. Richard or Simon
would likely be more helpful in this regard.

>> * 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?
>
That would be another approach but I don't believe this is possible with
our current typechecker plugin mechanism.. Specifically, I don't think
you can currently hide existing instances. In principle your plugin
could solve the unwanted instance with a TypeError but I'm not sure
whether this would work reliably with GHC's current implementation: I
believe that typechecker plugins are currently a fallback looked at
after the usual paths have failed. Moreover, even if it does work we
don't that guarantee solver behavior won't change in the future.

Cheers,

- Ben

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20200528/c976b3ed/attachment.sig>


More information about the Libraries mailing list