-
Notifications
You must be signed in to change notification settings - Fork 42
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
mtl module is member of hidden package #128
Comments
Which dependency list? hint doesn't know anything about your Instead, hint uses ghc-pkg, the package manager which comes with ghc. It stores packages in various folders called "package databases". stack and cabal both make use of ghc-pkg, and call ghc with various command-line arguments and environment variables which tell ghc which package databases to use. It is also possible to tell ghc to hide all the packages from the package databases it knows about, and to only unhide a select few packages. You can see the flags which do this using the
Your error message says that your module is a "member of the hidden package mtl", so the problem is definitely that your build system is somehow passing Now, in order to pass those flags to hint, you'd need to use the unnecessarily-scarily-named unsafeRunInterpreterWithArgs, but I assume you're using the ordinary runInterpreter, which doesn't pass any flags. So I am guessing that there is some other mechanism, like an environment variable or a |
I couldn't reproduce with
|
The output of |
Aha! I've managed to reproduce the problem with |
I can also reproduce with plain
The line
but it does not include the line Another interesting line is the recommendation to run import qualified Language.Haskell.Interpreter as Hint
import qualified Language.Haskell.Interpreter.Unsafe as Hint
test :: IO (Either Hint.InterpreterError ())
test = Hint.unsafeRunInterpreterWithArgs ["-package", "mtl"] $ do
Hint.setImports ["Control.Monad.State"] It would probably be a good idea to add a function to hint which behaves like ghci's |
Wow! Thanks for premium support ;)
unsafeRunInterpreterWithArgs and package arguments have no effect for me in stack demo project, but worked out in a nix project. |
I discovered additional info. ghc-pkg is not the only place for resolving dependencies. The project, I develop, uses nix and it has been upgraded to from ghc-8.10.2 to ghc-8.10.4 and I noticed new problem. Probably the existed before I just wasn't able to notice them. cabal builds my program. The program needs to use its own module inside hint (cabal library) inside nix-shell:
once I run a Haskell script imporintg MyPackage I get runtime error:
I started looking for the magic artifact.
Reference to so file is not inside elf file.
there is no hash suffix. ldd doesn't show anything either. inplace word grabbed my attention. https://cabal.readthedocs.io/en/latest/nix-local-build.html
Then I tried to remove lilbHSmylib.so from cabal store and put into current folder with
then app fails with new error:
build directory contains:
Definitely inplace cause the problem. It would nice to know how to reference program library as any other one. After further experimenting I detected that libHSmylib.so file is not need at all. It is not sufficient due missing RTS symbol stg_gc_unpt_r1, but next to this file I noticed static library libHSmylib-0.3.8-2b517a72dcdee51aa9773d0e2dad33ae67d9079beaf1f792beef208cb6cd1f07.a. The static lib make the difference. How come? Static library rescues runtime?! |
As the
In my case, this "global database" is
Remember, I don't recommend using hint to load module X from module X.
I'm not sure about that. I do know, however, that each package (or is it each module?) is compiled in two different forms: a compiled form and an interpreted form. ghci and hint both distinguish between loading a module and importing a module; the loaded modules are interpreted, whereas for the module which are imported but not loaded, the compiled version is used. Presumably there is some kind of shim in between which allows the interpreted code to call compiled functions and vice-versa. Maybe the |
...or even a module from package my-package from a module of my-package. |
Hi,
I noticed that modules from some packages are not available inside interpreter, while rest packages are loadable. I don't see why behavour is different.
In my case mtl package is in trouble but text package is not!
Both packages are on the same dependency list.
Could not load module \8216Control.Monad.State.Strict\8217\n It is a member of the hidden package \8216mtl-2.2.2\8217.\n You can run \8216:set -package mtl\8217 to expose it.\n (Note: this unloads all the modules in the current scope.)\n Use -v (or
:set -vin ghci) to see a list of the files searched for."}]
ghc 8.10.2
The text was updated successfully, but these errors were encountered: