error-messages
error-messages copied to clipboard
Better suggestion for data constructors import list
Here's an error message:
Data constructor not in scope:
NonRec :: Id -> GHC.Core.CoreExpr -> GHC.Core.Bind b0
Suggested fix:
• Perhaps you want to add ‘NonRec’ to the import list
in the import of ‘GHC.Core’
So I add import GHC.Core (NonRec) and I get:
In module ‘GHC.Core’:
‘NonRec’ is a data constructor of ‘Bind’
To import it use
import GHC.Core( Bind( NonRec ) )
or
import GHC.Core( Bind(..) )
The first error should suggest adding Bind (NonRec) directly.
The second error is good. Minor nitpick: it could use the "Suggested fix" header.
But adding Bind(NonRec) brings Bind into scope, too. A more direct way forward is to add pattern NonRec, which will bring in just the data constructor. Of course, you need -XPatternSynonyms for this. But if -XPatternSynonyms is on, suggesting pattern NonRec might be a nice way to teach users that this can be used for data constructor import.
Just came here to say that I run into this all the time.