Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qualify every use of Prelude functions (#131) #321

Merged
merged 1 commit into from
Oct 21, 2024
Merged

Qualify every use of Prelude functions (#131) #321

merged 1 commit into from
Oct 21, 2024

Conversation

sgraf812
Copy link
Collaborator

This bit end users in visq/language-c#99.

Properly fixes #131 and adds a regression test.

@Bodigrim
Copy link

This is a great improvement, but it might be nice to document somewhere that happy relies on Prelude being base:Prelude, because in general it can be overridden in Cabal file with something like mixins: base hiding (Prelude), relude (Relude as Prelude).

(I'm not sure whether it's possible or practical to resolve the general issue)

This bit end users in visq/language-c#99.

Properly fixes #131 and adds a regression test.
@sgraf812
Copy link
Collaborator Author

I had hoped to import Prelude qualified as Happy_Pre and then use a package import, but that means that the implicit import Prelude is no longer inserted (Section 5.6.1 of the Haskell report).

So happy cannot by itself add a qualified import of Prelude without surprising effect on user programs.
It appears that users who import Prelude (...) or redefine Prelude must also import qualified "base" Prelude. It's a bit ugly, but not too complicated to detect and adhere to.

I documented this in the user's guide.

@sgraf812 sgraf812 merged commit 69e7bc1 into master Oct 21, 2024
26 checks passed
@andreasabel
Copy link
Member

This PR broke Agda:

Because our parser has import Prelude hiding (null) another import qualified Prelude has to be omitted by the generator to have Prelude.null in scope.

I think 2.1.1 should be deprecated as it pretends to be a minor bump but breaks user's code.

I'll open a new issue for all that, no need to reply here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

qualify Prelude functions in templates?
3 participants