Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to write hints for typeclass instances? #1440

Open
telser opened this issue Jan 9, 2023 · 1 comment
Open

Is it possible to write hints for typeclass instances? #1440

telser opened this issue Jan 9, 2023 · 1 comment

Comments

@telser
Copy link

telser commented Jan 9, 2023

It doesn't seem that this is possible currently, but perhaps I'm missing something. There are a couple of use cases for this that have come up for me.

One is being able to enforce that enumFrom is defined in an instance of Enum, as we've encountered trouble in a couple of codebases now where an expectation with arises with the default of an infinite enumeration, but we more frequently have finite ones.

The second is to be able to say that '(/=)' is not defined, to prepare for that becoming not a typeclass method. This second use case would be fantastic for the HF stability working group to be able to promote as way to help the community smooth over transitions like this in a general way.

@ndmitchell
Copy link
Owner

Not currently. There are two ways to go to add it:

  1. Add a generic mechanism inside HLint to require that a class instance is/isn't defined.
  2. Add custom hints built in at the Haskell layer that validate the type class.

Given the two instances you have both are built in to the base library, doing a custom hint in the Haskell layer seems reasonable. I guess I wonder if there are more instances you might want to hint in the future?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants