Skip to content

Allow things to be hidden from Prim#2951

Merged
garyb merged 1 commit intopurescript:masterfrom
garyb:2499-prim-hiding
Jun 25, 2017
Merged

Allow things to be hidden from Prim#2951
garyb merged 1 commit intopurescript:masterfrom
garyb:2499-prim-hiding

Conversation

@garyb
Copy link
Copy Markdown
Member

@garyb garyb commented Jun 25, 2017

Resolves #2499

@garyb garyb force-pushed the 2499-prim-hiding branch from cec1ebe to 033f392 Compare June 25, 2017 16:54
purescript.cabal Outdated
test-suite tests
build-depends:
aeson >=1.0 && <1.2
aeson >=1.0 && <1.1
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, looks like that PR that went in changed this instead of the package.yaml. Maybe this should be removed from and gitignored in the repo now, if we're relying on hpack?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need both if we want Cabal users to be able to build things.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this has happened too many times now; I think we do need to either gitignore the cabal file or stop using hpack. I'm not particularly attached to one option over the other but if it was solely up to me I'd probably go for stopping using hpack.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be fine with not using hpack.

@garyb
Copy link
Copy Markdown
Member Author

garyb commented Jun 25, 2017

For the record, when digging into this I discovered the environment was being initialized for every module as if it had these imports

import Prim
import Prim as Prim

regardless of what the user was doing. Now it allows these imports to be rewritten if they are specifically included. It's not great that it needs importing with and without qualification, but I have an idea about how to fix that as part of the fix for #1647 too. It's currenty necessary to have it qualified as generated names (like when {} is desugared into Prim.Record) still go through the name desugaring process, so the usual rules about the available scope apply. I'm thinking some generated names should/can be handled differently. This is a knock-on from the change a while back that only allows explicitly imported things to be resolved, even if fully qualified.

@paf31
Copy link
Copy Markdown
Contributor

paf31 commented Jun 25, 2017

Can you explain a little more why we need both imports, maybe by giving an example? I'm not seeing it.

@garyb
Copy link
Copy Markdown
Member Author

garyb commented Jun 25, 2017

type Test = {}

is desugared into

type Test = Prim.Record ()

With no import Prim as Prim it complains that Prim.Record is unknown.

@paf31
Copy link
Copy Markdown
Contributor

paf31 commented Jun 25, 2017

I assume this is to do with the order in which the various desugaring steps happen? Couldn't we just desugar it to Record (unqualified) then?

@paf31 paf31 closed this Jun 25, 2017
@paf31 paf31 reopened this Jun 25, 2017
@garyb
Copy link
Copy Markdown
Member Author

garyb commented Jun 25, 2017

I assume this is to do with the order in which the various desugaring steps happen?

Well, kinda. Desugaring isn't the right term I guess, since it comes directly out of the parser as Prim.Record, so the other representation is lost before we get to the AST even.

Couldn't we just desugar it to Record (unqualified) then?

We could, but that only works if someone hasn't done import Prim hiding (Record), and/or defined type Blah = Record. I suppose it's true someone could still do import Prim (String) as Prim and still break it, but... whatever - like I said, I'll have another fix for that aspect soon 😛. This change is only an improvement on what we have, it's not adding something that didn't used to occur, it's just now it's done in one place rather than two.

@garyb garyb force-pushed the 2499-prim-hiding branch from 033f392 to 81f5712 Compare June 25, 2017 20:04
@garyb garyb merged commit 3dca6b7 into purescript:master Jun 25, 2017
@garyb garyb deleted the 2499-prim-hiding branch June 25, 2017 23:48
@garyb garyb mentioned this pull request Jul 4, 2017
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.

3 participants