atom-haskell / ide-haskell-repl

GHCi REPL in Atom
https://atom.io/packages/ide-haskell-repl
MIT License
26 stars 8 forks source link

Other modules are not loaded #71

Open freeman42x opened 4 years ago

freeman42x commented 4 years ago

Extension is set to use cabal-v2

Running cabal v2 repl in terminal correctly loads other modules.

When opening the extension following message is shown:

These modules are needed for compilation but not listed in your .cabal file's other-modules: 
    OS.Linux.NixOS
/home/neo/Projects/haskell-editor-setup/src/Main.hs: 70, 56: error: • Couldn't match type ‘Action -> IO ()’
             with ‘Language.Javascript.JSaddle.Types.JSContextRef’
Expected type: Sub Action
Actual type: Language.Javascript.JSaddle.Types.JSContextRef
             -> JSM ()
• In the second argument of ‘($)’, namely ‘runJSM nixOsAtom’
In the expression: effectSub model $ runJSM nixOsAtom
In an equation for ‘updateModel’:
  updateModel Install model = effectSub model $ runJSM nixOsAtom</div><div>/home/neo/Projects/haskell-editor-setup/src/Main.hs: 70, 63: error: • Couldn't match expected type ‘JSM ()’
          with actual type ‘Sink action0 -&gt; IO ()’
• Probable cause: ‘nixOsAtom’ is applied to too few arguments
In the first argument of ‘runJSM’, namely ‘nixOsAtom’
In the second argument of ‘($)’, namely ‘runJSM nixOsAtom’
In the expression: effectSub model $ runJSM nixOsAtom
freeman42x commented 4 years ago

This happens even if all code can compile successfully.

freeman42x commented 4 years ago

And even though it says it could not load the modules, it actually loaded them since I can type check symbols from other modules.

freeman42x commented 4 years ago

Aight, so I can just Clear output and ignore that message. But would be good if it would be fixed.

lierdakil commented 4 years ago

Okay, so I'm a little confused about what's going on here exactly, but there are two distinct messages you're seeing. The first one,

These modules are needed for compilation but not listed in your .cabal file's other-modules: 
    OS.Linux.NixOS

is a warning from cabal. It loads the modules, but complains those aren't listed in other-modules.

The second one,

/home/neo/Projects/haskell-editor-setup/src/Main.hs: 70, 56: error: • Couldn't match type ‘Action -&gt; IO ()’
             with ‘Language.Javascript.JSaddle.Types.JSContextRef’
etc

actually complains about an error in haskell-editor-setup/src/Main.hs. I don't know whether it is related to the project you're working with, or if it's something loaded from $HOME/.ghci or elsewhere.

Unless this is a subtle error in environment set-up that ide-haskell-repl performs on start, this doesn't seem to be an issue with the package itself?

I'm not sure where I could start with investigating this. If you could construct and publish a testcase that would help a lot.

freeman42x commented 4 years ago

@lierdakil You can reproduce the issue by opening the REPL in this project: https://github.com/fairy-tale-agi-solutions/haskell-editor-setup

You can ignore the compile issue, as I said it's not important and the message about the other modules not being loaded will be displayed regardless.

Project above is configured to build with Nix, but I guess you can use cabal for it also and hopefully it will also help reproduce the bug.

If there is anything I can do on my machine to help you figure it out that would be great.

freeman42x commented 4 years ago

Ah, this actually affects functionality since when reload on file save is active the message pops up again on each reload.

freeman42x commented 4 years ago

@lierdakil is there any easy way to copy the messages displayed by the ide-haskell-repl? Like the message mentioned above. When I try to select the text nothing happens. And there is no copy option in the right click menu.

lierdakil commented 4 years ago

Are you perchance using ide-haskell-repl without ide-haskell? Because with ide-haskell, repl messages are displayed in "repl" tab in ide-haskell panel, which is selectable.

lierdakil commented 4 years ago

Probably so. If I'm correct in my guess, then I've published v0.9.5 which makes the error div selectable (this was an oversight on my part)

lierdakil commented 4 years ago

As for the rest, I've failed miserably at building the project. It builds with nix, provided dependencies are in the right places (miso specifically), but cabal v2-repl still complains about missing external libraries, even when run from nix-shell.

So if you're willing to debug this on your side, that's probably a faster option. To start with, I'd like to see if ghci runs the way one would expect it to, where one would expect it to. The easiest way to check this is to tap child_process.spawn function. You can do it by running the following snippet in the dev console:

oldspawn = require('child_process').spawn; require('child_process').spawn=function(...args){console.log(...args); return oldspawn(...args);}

After that, open REPL and look at console output. I expect to see something like

cabal ["v2-repl"] {cwd: "/home/neo/Projects/haskell-editor-setup", stdio: Array(3)}

The one I'm the most curious about is cwd, since the output suggests it's perhaps finding the wrong cabalfile.

As a side note, I'm genuinely curious about how you've set up your environment to let cabal pick up on nix-shell stuff.

freeman42x commented 4 years ago

@lierdakil thank you for the quick update, now I can copy paste the messages shown by the extension

freeman42x commented 4 years ago

Are you perchance using ide-haskell-repl without ide-haskell?

Yeah, for some reason ide-haskell was not installed and I do not recall why. Might have been some clash with haskell-ide-engine plugin maybe. After I installed it then the message was no longer shown inside the extension and was shown under error/repl in IDE-Haskell tab like you said.

freeman42x commented 4 years ago

@lierdakil I forgot that the build would require some steps which are not documented such as pointing default.nix to a patched Miso branch: https://github.com/fairy-tale-agi-solutions/miso/tree/fix and using lorri / direnv cause that sets a environment variable necessary for GUI to work properly. Previous steps should help you build it if you want to give it a try.

freeman42x commented 4 years ago

It's spamming lot of:

{cwd: "/home/neo/Projects/haskell-editor-setup", stdio: Array(3)}

As a side note, I'm genuinely curious about how you've set up your environment to let cabal pick up on nix-shell stuff.

Using cabal2nix which provides the haskell packages via nix. I hope I got the question right.

Going to write documentation on how to build the project soon but if you want to give it a try, the basic steps I mentioned above.

freeman42x commented 4 years ago

After enabling ide-haskell Atom started crashing and also the REPL stopped working. The message:

These modules are needed for compilation but not listed in your .cabal file's other-modules: 
OS.Linux.NixOS

seems to have actually be accurate that it could not find them for usage in the REPL.

lierdakil commented 4 years ago

Atom started crashing

Well, that's certainly unexpected =\

I hope I got the question right.

No, what I was asking is this: at least on my system, cabal fails to find a lot of external dependencies (i.e. non-Haskell libraries like webkitgtk) when run under nix-shell, despite those dependencies being in the nix-shell environment. So while building with nix-build might work fine, running something like cabal repl doesn't work. But I'm not on NixOS.

freeman42x commented 4 years ago

@lierdakil If you use steps I mentioned above then cabal repl should work fine under nix-shell. When you run nix-shell that should install everything required. It is possible though that some program I have globally installed on my system provides libraries which you are mentioning. webkitgtk might come from Chrome for example.