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

.ghc.environment files should probably support thinning and renaming #5963

Closed
23Skidoo opened this issue Mar 26, 2019 · 3 comments
Closed

.ghc.environment files should probably support thinning and renaming #5963

23Skidoo opened this issue Mar 26, 2019 · 3 comments

Comments

@23Skidoo
Copy link
Member

Let's say that I use the following common stanza to replace the standard Prelude with ClassyPrelude:

common classy-prelude
  build-depends:       base >=4.11 && <4.13
                     , classy-prelude
  mixins:              base hiding (Prelude)
                     , classy-prelude (ClassyPrelude as Prelude)

This results in approximately the following flags being passed to ghc:

-package-id 'base-4.12.0.0 (Control.Applicative, Control.Arrow, [... lots of module names omitted])' -package-id 'classy-prelude-1.5.0-ad629aa84... (ClassyPrelude as Prelude)'

The problem now is that the generated .ghc.environment file looks like this:

package-id base-4.12.0.0
[...]
package-id classy-prelude-1.5.0-ad629aa84...

That is, information about thinning and renaming has been lost, which, unfortunately, breaks tools that rely purely on the environment file, such as ghcid. It looks like this should be also fixed on the GHC side, since the package environment files don't seem to support the full thinning and renaming syntax that GHC's -package-id option supports.

Related: #5962.

/cc @hvr

@23Skidoo 23Skidoo changed the title .ghc.environment files should support thinning and renaming .ghc.environment files should probably support thinning and renaming Mar 26, 2019
@23Skidoo
Copy link
Member Author

23Skidoo commented Mar 26, 2019

I sort of managed to work around this with :set -hide-package base -package "classy-prelude (ClassyPrelude as Prelude)" in .ghci, but then ghcid itself starts producing weird errors:

<interactive>:1:1: error:
    Ambiguous module name ‘Prelude’:
      it is bound as ClassyPrelude by a package flag
      it is bound as base-4.12.0.0:Prelude by package base-4.12.0.0

<interactive>:9:1: error:
    Not in scope: ‘INTERNAL_GHCID.putStrLn’
    No module named ‘INTERNAL_GHCID’ is imported.

<interactive>:10:1: error:
    Not in scope: ‘INTERNAL_GHCID.hPutStrLn’
    No module named ‘INTERNAL_GHCID’ is imported.

<interactive>:10:26: error:
    Not in scope: ‘INTERNAL_GHCID.stderr’
    No module named ‘INTERNAL_GHCID’ is imported.

Anyway, on second thought, this kind of thing should probably be handled by cabal new-repl rather than environment files, though that currently doesn't work that well for me either.

@phadej
Copy link
Collaborator

phadej commented Mar 26, 2019

ghcid -c 'cabal new-repl'

@23Skidoo
Copy link
Member Author

Yeah, I tried that, but it doesn't work that great either. I guess I should close this ticket and open new ones about improving new-repl.

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

No branches or pull requests

2 participants