You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
M.hs:8:3: error:
‘toConstr’ is not a (visible) method of class ‘Data’
|
8 | toConstr = undefined
| ^^^^^^^^
M.hs:9:3: error:
‘gunfolt’ is not a (visible) method of class ‘Data’
|
9 | gunfolt = undefined
| ^^^^^^^
Contrast with:
moduleM2whereimportData.Data (Data (gunfold))
a = toConstr
b = gunfolt
where I get helpful suggestions:
M2.hs:5:5: error:
• Variable not in scope: toConstr
• Perhaps you want to add ‘toConstr’ to the import list
in the import of ‘Data.Data’ (M2.hs:3:1-33).
|
5 | a = toConstr
| ^^^^^^^^
M2.hs:6:5: error:
• Variable not in scope: gunfolt
• Perhaps you meant ‘gunfold’ (imported from Data.Data)
|
6 | b = gunfolt
| ^^^^^^^
A cheap fix would be just to list all visible methods of the class in the error, classes usually don't have that many members.
data Foo a = Foo a deriving (Functor)
instance Applicative (Foo) where
pure = Foo
gives
warning: [-Wmissing-methods]
• No explicit implementation for
either ‘<*>’ or ‘GHC.Base.liftA2’
Attempting to follow the suggestion,
instance Applicative Foo where
pure = Foo
GHC.Base.liftA2 f (Foo a) (Foo b) = Foo $ f a b
gives
‘GHC.Base.liftA2’ is not a (visible) method of class ‘Applicative’
|
10 | GHC.Base.liftA2 f (Foo a) (Foo b) = Foo $ f a b
| ^^^^^^^^^^^^^^^
Qualified name in binding position: GHC.Base.liftA2
|
10 | GHC.Base.liftA2 f (Foo a) (Foo b) = Foo $ f a b
| ^^^^^^^^^^^^^^^
liftA2 is now be exported from Prelude in ghc master, but the general problem remains. The error message should suggest adding an import.
If I refer to an unknown method in a class
I get this error:
Contrast with:
where I get helpful suggestions:
A cheap fix would be just to list all visible methods of the class in the error, classes usually don't have that many members.
Related: #13, about associated types.
The text was updated successfully, but these errors were encountered: