error message suggests variables in a pattern
In this reddit thread the OP posts some code with a confusing error message.
The relevant code is:
import qualified Data.Map as Map
instance Functor (Map.Map k) where
fmap f (Map.Map k v) = undefined
For which GHC 8.10.4 produces the error message:
MapAsFunctor.hs:4:11: error:
Not in scope: data constructor ‘Map.Map’
Perhaps you meant variable ‘Map.map’ (imported from Data.Map)
Module ‘Data.Map’ does not export ‘Map’.
|
4 | fmap f (Map.Map k v) = undefined
| ^^^^^^^
Clearly Map.map
cannot be used in this pattern so this is a bad suggestion. GHC should only suggest constructors and pattern synonyms in this case.