haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

More code actions when a default method implementation doesn't work

Open akshaymankar opened this issue 3 years ago • 3 comments

Is your enhancement request related to a problem? Please describe.

When writing code like this:

instance FromJSON Foo

This produced an error about Foo not having an instance for Generic due to the default implementation of parseJSON and HLS sugests that I make the line look like

instance Generic Foo => FromJSON Foo

This is almost never what anyone wants to do for most type classes.

Describe the solution you'd like

I understand that in the general case, this might be a good idea, like when the constraint is on a parameter of the type in question. So this suggestions shouldn't be removed. I think having these two other suggestions would be greatly helpful for me:

  1. A suggestion to add placeholders for the missing methods, like the hls-class-plugin does.
  2. A suggestion to add another instance for the type instead of just the constraint.

Describe alternatives you've considered

N/A.

Additional context

N/A.

akshaymankar avatar Sep 02 '22 06:09 akshaymankar

This seems like a reasonable feature request. Is this something you're interested in trying to implement?

wz1000 avatar Sep 07 '22 11:09 wz1000

Yes I am interested in implementing it. I am planing to be at Munihac next Month and I am not sure if I will find time to work on this until then. If nobody else has taken stab at this by then I can hack on this there.

akshaymankar avatar Sep 07 '22 11:09 akshaymankar

I see the label component:hls-class-plugin on this, I would like to point out that the current code action comes from ghcide, so this would definitely involve some work on ghcide.

akshaymankar avatar Sep 07 '22 11:09 akshaymankar