haskell / haskell/haskell-language-server

Class plugin cannot handle classes with default methods under some unsatisfied constraints

Open
#2,496 0 comments 0 reactions 0 assignees View on GitHub
component: hls-class-plugin type: enhancement
Dominant language
Haskell
Stars
3k
Forks
455
Avg merge
2d 19h
Merged PRs (30d)
11

Description

**Is your feature request related to a problem? Please describe.**

Class plugin cannot suggest minimal methods when a target class have default implementations for the methods under some constraints, and the type of the target instance can't satisfy the constraints. For example, with this class:
```Haskell
class FromJSON a where
parseJSON :: Value -> Parser a

default parseJSON :: (Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
parseJSON = ...
```
the following code just gives an error without a suggestion for `parseJSON`:
```Haskell
data MyType = MyType Int Bool

instance FromJSON MyType
```

**Describe the solution you'd like**

Check whether the error happening because of default implementation or not, and if so, suggest minimal methods to handle the error.

**Describe alternatives you've considered**

Provide another `instance` declaration so that the default methods can be used. However, this default implementation is not always what a user wants. (Maybe this can be a complement of the above suggestion)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.