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

Mixins are not accounted when trying to hide Prelude #823

Closed
Martoon-00 opened this issue Oct 29, 2020 · 5 comments
Closed

Mixins are not accounted when trying to hide Prelude #823

Martoon-00 opened this issue Oct 29, 2020 · 5 comments

Comments

@Martoon-00
Copy link

Problem

In one of the projects, we are trying to use mixins feature to hide the default Prelude module and provide our own, in overall this looks like

# package.yaml
depedencies:
  - name: base
    version: ">= 4.7 && < 5"
    mixin: [hiding (Prelude)]
  - morley-prelude

However, it looks like hiding Prelude does not work, because with ghcide I get the following error

Ambiguous module name ‘Prelude’:
  it was found in multiple packages:
  base-4.13.0.0 morley-prelude-0.3.0

Reproduction

I can reproduce this in the Morley repository, commit e9a00b61bb.
It has morley-prelude package used as a custom prelude. When I open some of the depending packages, e.g. code/morley/src/Util/Text.hs file from morley package, I get the mentioned error for all modules.
There are other packages using morley-prelude where the problem reproduces, e.g. morley-ledgers has much less modules (in case that is helpful), but it appears in a different repository.

Side comments

Indeed, one of the options for us would be just not using mixins and instead use base-noprelude. We are going to apply this as a temporary workaround, though it would be nice if this feature is eventually supported.

I'm not sure how problematic this may be to fix, since it is a known issue that even stack ghci does not work with mixins properly, but would be nice to at least know your plans on this.

@wz1000
Copy link
Collaborator

wz1000 commented Oct 29, 2020

I'm not sure how problematic this may be to fix, since it is a known issue that even stack ghci does not work with mixins properly, but would be nice to at least know your plans on this.

This might be linked, since ghcide gets its flags by asking stack for them. Have you tried using a cabal cradle? Otherwise try hie-bios check SomeFile.hs, or running ghci with the flags returned by hie-bios dump.

@Martoon-00
Copy link
Author

I have some severe issues with making cabal work.

hie-bios check reports the same Ambiguous module name ‘Prelude’ ... error.

Tried hie-bios dump, though somehow it doesn't have such a command (using hie-bios version 0.5.1 compiled by GHC 8.8.3)

@wz1000
Copy link
Collaborator

wz1000 commented Oct 29, 2020

Sorry, I meant hie-bios flags.

However, hie-bios check not working means this is likely an upstream issue with the flags stack is telling us to use.

@jneira
Copy link
Member

jneira commented Oct 29, 2020

I think it could be hie-bios debug.
As @wz1000 commented stack repl does not work with mixin and hie-bios needs to call stack repl underneath to give build info to ghcide. stack issue is commercialhaskell/stack#5077
So i am afraid that there is no much to do but use cabal ot not use mixins

@Martoon-00
Copy link
Author

Martoon-00 commented Oct 29, 2020

hie-bios flags / debug mention -package-id=base-4.13.0.0 among options without mentioning mixins, and if those flags are all the information provided by hie-bios for compilation, then apparently this is there the attempt to hide Prelude fails.

If there are other issues with hie-bios like the one you mentioned, that it needs stack repl, then things seem to be even sadder.

I suppose I will report an issue in hie-bios then and close this issue until something changes upstream. Thanks for the quick reply!

@pepeiborra pepeiborra transferred this issue from haskell/ghcide Jan 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants