hint
hint copied to clipboard
Can't use identifiers from loaded modules
Minimal repro:
-
Write a file
Foo.hs
likemodule Foo where x :: Int x = 1
-
Run
stack ghci --package hint
, then in the shell, do:import qualified Language.Haskell.Interpreter.Hint import Control.Monad.IO.Class Hint.runInterpreter $ do { Hint.loadModules ["Foo.hs"]; liftIO . print =<< Hint.getModuleExports "Foo"; Hint.eval "x" }
The output I see is:
[Fun "x"]
Left (WontCompile [GhcError {errMsg = "<interactive>:3:1: error: Variable not in scope: x"}])
which shows that x
was loaded, but evaluating it doesn't work. Same thing happens with other functions like typeOf
:sparkles: This is an old work account. Please reference @brandonchinn178 for all future communication :sparkles:
Ah I guess I have to do
loadModules ["Foo.hs"]
setTopLevelModules ["Foo"]
eval "x"
is that intended? If so, the docs could clarify what the difference between loadModules and setTopLevelModules intends
I have clarified the behaviour of loadModules
in the documentation, which will be updated in the next release.
Here is the updated documentation: https://github.com/haskell-hint/hint/pull/160/files#diff-e54c923347aee61efe6f22a52e9d2f061feaf554ef594a2e1a430f7da639306aR190-R193