haskell / haskell/haskell-language-server
Code action to add deriving instance
- Dominant language
- Haskell
- Stars
- 3k
- Forks
- 455
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 13
Description
**Is your feature request related to a problem? Please describe.**
I'd like a way to add an instances to the `deriving` clause of a type (and related type).
For example, I just tried to `deepseq` on a type in our codebase, and that type had no `NFData`. It took me something like 2 hours (and would have be way more without HLS) to just jump to definition of type, add the instance, jump to the definition of sub types, add the instances, add import, add `LANGUAGE` for `DerivingGeneric`, jump to another type. Rinse and repeat.
**Describe the solution you'd like**
I'd like, in case of `Could not deduce (InstanceName AType)` error, to have a code action `Add instance InstanceName to AType`.
As a first step, it would jump to the type and add the instance to the `deriving` clause. As a second step, it would be great if it could recursively add the instance to all the related types (i.e. loop until there is no more `Could not deduce ...` error.
Some questions:
- In case of `DerivingStrategies`, In which clause should the instance go?
- What if we need to add some `LANGUAGE` pragma?
- What if we need to add some `import`
- Can we do the recursive addition in one step, or should we iterate until there is no more error message? What about performances here?
**Describe alternatives you've considered**
Not adding this plugin?
**Additional context**
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue names no files or tests. Start by locating the existing HLS code-action path for “Could not deduce (InstanceName AType)” diagnostics, then map how type definitions and deriving clauses are represented. Done means offering an action that adds the requested instance while resolving the stated questions about deriving strategies, language pragmas, imports, and recursive related types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100