Cannot generate instances from other modules when using default qualification options
Unless I am missing something, generating instances for instances from other modules is currently not possible. Consider the following class declaration:
module M where
class C a where
doSomething :: a -> String
Generating a syntax tree with qualified identifiers yields
module N where
import qualified M
data X = X
instance M.C X where
M.doSomething = ...
The problem is that M.doSomething
is not a valid left-hand side of a function rule. Using an unqualified doSomething
identifier, however, also results in an error, in that case that the method is not visible, which makes sense given that the import is only qualified.
So I see two (not necessarily mutually exclusive) solutions here:
- Have the prettyprinter deal with the correct imports and generate an unqualified function name even if the name is qualified in the tree
- Let the user specify unqualified imports
Edited by Fredrik Wieczerkowski