Skip to content

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

Open
@Ailrun

Description

@Ailrun

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:

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:

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions