Open MorrowM opened 2 years ago
Ideally, it would also be nice if the error message didn't mention module headers or import declarations in places where it doesn't apply, such as in this example:
What determines whether or not the module scenario applies? How does a user (or the code) know the module scenario is not applicable?
Module headers need to be near the top, right below the pragmas. Module headers can't go below imports or top-level bindings. Similarly imports can't go below top-level bindings and they can't go above the module header.
Should close #34 or this as duplicates?
(copied from #34 as requested)
I think the idea is that this first does parse, because of those dastardly TH implicit top level splices, and then this warning is issued.
If so, I think that does in fact mean we have enough info to make this error better: as we comb through the list of "rawer top-level items", we can vary what we suggest based on what we've already seen.
This fits well with the general principle rather than parsing an AST in nearly one pass, very incrementally parse into increasingly less liberal ASTs, starting with a super liberal one, so we get better errors.
Given this module:
We get this error when loading it into GHCi:
Perhaps we can:
Suggested error message:
Ideally, it would also be nice if the error message didn't mention module headers or import declarations in places where it doesn't apply, such as in this example: