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

Backpack mixins works except for module hiding #327

Closed
habibalamin opened this issue Oct 4, 2020 · 12 comments
Closed

Backpack mixins works except for module hiding #327

habibalamin opened this issue Oct 4, 2020 · 12 comments

Comments

@habibalamin
Copy link

habibalamin commented Oct 4, 2020

Hi,

I have a Cabal file with a mixins field set to:

  mixins:              base hiding (Prelude)
                     , protolude (Protolude as Prelude)

If I run ghcid like so:

cabal v2-exec ghcid -- -c 'cabal v2-repl'

or

cabal v2-exec ghcid

it results in an error message like this:

src/lib/ASDR.hs:1:8: error:
    Ambiguous module name ‘Prelude’:
      it is bound as Protolude by a package flag
      it is bound as base-4.14.0.0:Prelude by package base-4.14.0.0
  |
1 | module ASDR where
  |        ^^^^

This is a new project, so I'm not using the modules yet, just importing them, so I can remove the mixins field and observe that everything works as expected. I can also keep the mixins field and just run cabal v2-repl and again, everything works as expected.

Changing base hiding (Prelude) to base (Prelude as SomeRandomOtherModuleName) doesn't help either; I get the same exact error message, which is weird, because it suggests it's picking up the Protolude -> Prelude mapping, but not the Prelude -> SomeRandomOtherModuleName mapping (or maybe it's both retaining the old names and picking up the new names?).

@habibalamin
Copy link
Author

Hmm, this looks suspiciously relevant.

@ndmitchell
Copy link
Owner

Does cabal v2-repl on its own work? Ghcid roughly runs the repl, so if the underlying repl doesn't work, Ghcid won't. If you can get a working repl, then is the point to try and turn it into a Ghcid session. Personally, I've no idea about mixins.

@habibalamin
Copy link
Author

habibalamin commented Oct 5, 2020

Yes, it does. I even copied and pasted the default cabal repl command that ghcid prints out that it's running and that works, too. I spent ages looking at the ghcid codebase, because GHCi seems to do the right thing here, but couldn't find anything.

Using base-noprelude doesn't work with protolude either; Cabal complains:

Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: applescript-dictionary-reader-0.1 (user goal)
[__1] trying: protolude-0.3.0 (dependency of applescript-dictionary-reader)
[__2] trying: base-4.14.0.0/installed-4.14.0.0 (dependency of protolude)
[__3] next goal: base-noprelude (dependency of applescript-dictionary-reader)
[__3] rejecting: base-noprelude-4.13.0.0 (conflict:
base==4.14.0.0/installed-4.14.0.0, base-noprelude => base==4.13.0.0)
[__3] skipping: base-noprelude-4.12.0.0, base-noprelude-4.11.1.0,
base-noprelude-4.11.0.0, base-noprelude-4.10.1.0, base-noprelude-4.10.0.0,
base-noprelude-4.9.1.0, base-noprelude-4.9.0.0, base-noprelude-4.8.2.0,
base-noprelude-4.8.1.0, base-noprelude-4.8.0.0, base-noprelude-4.7.0.2,
base-noprelude-4.7.0.1, base-noprelude-4.7.0.0, base-noprelude-4.6.0.1,
base-noprelude-4.6.0.0, base-noprelude-4.5.1.0, base-noprelude-4.5.0.0,
base-noprelude-4.3.1.0, base-noprelude-4.3.0.0 (has the same characteristics
that caused the previous version to fail: excludes 'base' version 4.14.0.0)
[__3] fail (backjumping, conflict set: applescript-dictionary-reader, base,
base-noprelude)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, base-noprelude,
applescript-dictionary-reader, protolude
Try running with --minimize-conflict-set to improve the error message.

@ndmitchell
Copy link
Owner

I'm confused. You are saying cabal v2-repl works on its own to get you into a repl? If so, ghcid -c "cabal v2-repl" should work as well. I note the two things you've listed don't include that, so maybe that's the issue?

@ndmitchell
Copy link
Owner

There's the separate issue of whether ghcid defaults to the right thing - which is worth addressing - but I suggest we figure out how to get it working manually first, and then see about updating the defaults.

@habibalamin
Copy link
Author

habibalamin commented Oct 6, 2020

Yes, cabal v2-repl works and cabal v2-exec ghcid -- -c 'cabal v2-repl' doesn't (let alone something like cabal v2-exec ghcid -- -c 'cabal v2-repl --repl-options=-fno-code'). I'm as confused as you are.

EDIT: just tried ghcid -c 'cabal v2-repl' without the cabal v2-exec and it works. Does this behaviour make sense to you?

@ndmitchell
Copy link
Owner

Yes, the cabal v2-exec sets up things such that cabal v2-repl doesn't work. I imagine cabal v2-exec -- cabal v2-repl would also fail for you.

@habibalamin
Copy link
Author

habibalamin commented Oct 6, 2020

Yep, sure enough that breaks in the same way.

Not sure if I should leave this issue open (with a new title and edited first comment). It still seems like buggy, or at least surprising, behaviour to me. I'm so used to prepending $ISOLATION_TOOL exec $ISOLATED_EXECUTABLE [-- "$@"] to make sure I always run the right version.

Maybe that was the wrong thing in this case, anyway, since I didn't put ghcid in the Cabal file. I guess I just ran it to make sure ghcid picked up my project, but I guess since it runs cabal v2-repl itself, it's already doing that.

@ndmitchell
Copy link
Owner

Maybe open it upstream on the Cabal github tracker? Since it seems like it's their issue underneath.

@habibalamin
Copy link
Author

I'm gonna close this, and defer the decision of whether to open a new issue linked to this one to you. I've spent too long on this, even tried to hack up a FIFO-based solution, but ran into this issue any time I tried to run a function when running with --repl-options=-fno-code:

ghc: ^^ Could not load '_applescriptzmdictionaryzmreaderzm0zi1zminplacezmlibasdr_ASDR_asdr_closure', dependency unresolved. See top entry above.


ByteCodeLink.lookupCE
During interactive linking, GHCi couldn't find the following symbol:
  applescriptzmdictionaryzmreaderzm0zi1zminplacezmlibasdr_ASDR_asdr_closure
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session.  Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please report this as a GHC bug:
  https://www.haskell.org/ghc/reportabug

@ndmitchell
Copy link
Owner

If you have -fno-code then you can't run functions - those things are incompatible. -fno-code makes things go faster, but if you want to run too, you have to not pass it.

@habibalamin
Copy link
Author

Ah, I see now that ghcid skips that option if I pass a -T argument. That makes sense.

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

2 participants