Skip to content

Suggest to use the where keyword for a typeclass instance when it's missing

Motivation

When I forget to add the where keyword when I create a typeclass instance I get a confusing error message.

module Example where

instance Show
  show = undefined
> [14 of 15] Compiling Example
> 
> project/src/Example.hs:4:8: error: parse error on input =
>   |
> 4 |   show = undefined

Proposal

Describe your proposed feature here.

I think the error message could be improved by suggesting that I may have missed the where keyword.

For example:

> [14 of 15] Compiling Example
> 
> project/src/Example.hs:4:8: error: parse error on input ‘=’
>   |
> 4 |   show = undefined

Perhaps you meant:
instance Show where
  show = undefined
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information