atom-haskell / ide-haskell-hls

Haskell Language Server support in Atom+IDE-Haskell
MIT License
1 stars 0 forks source link

Could not load module ‘HaskellSay’ #1

Open tdiesler opened 3 years ago

tdiesler commented 3 years ago

Following the cabal getting stared guide, I created a project structure like this

image

In Atom I then get an error like this

/Users/tdiesler/git/plutus-pioneer-program/futurelearn/week02/src/starman.hs: 1, 8
Could not load module ‘HaskellSay’
It is a member of the hidden package ‘haskell-say-1.0.0.0’.
You can run ‘:set -package haskell-say’ to expose it.
(Note: this unloads all the modules in the current scope.)

The project cabal file contains this ...

executable starman
    main-is:          starman.hs
    hs-source-dirs:   src

    -- Modules included in this executable, other than Main.
    -- other-modules:

    -- LANGUAGE extensions used by modules in this package.
    -- other-extensions:

    build-depends:    base ^>= 4.14,
                      haskell-say ^>= 1.0,
                      random ^>= 1.2

    default-language: Haskell2010

The same happens with import System.Random

The project works with cabal repl and cabal run :starman

lierdakil commented 3 years ago

Hi. What backend are you using? ide-haskell-repl or ide-haskell-hls? In any case, it might be that you just need to reload the backend to force it to reread the cabal file. By far the simplest way to achieve this is to run Window: Reload from Atom command palette.

tdiesler commented 3 years ago

I have this installed ...

image

The program works in ide-haskell-repl as well. Ctrl+Shift+P => Window: reload makes no difference unfortunately.

I installed HLS like this

ghcup install hls
lierdakil commented 3 years ago

Hmm. I have a suspicion of what goes wrong exactly. Could you try opening week02 directory in Atom instead of the parent directory futurelearn? You can do that from Atom by right-clicking on the week02 in the tree view and selecting "open in new window".

tdiesler commented 3 years ago

Yes, that works. So the cabal file must be in the root folder of the project? https://github.com/tdiesler/plutus-pioneer-program/tree/mystuff/futurelearn

lierdakil commented 3 years ago

Apparently so, but tbh it's an accident. I'll try to see if I can do something about it. In the meantime, I think cabal.project file in futurelearn directory with the following contents should convince hls to pick up the correct cabal file:

packages: */*.cabal
tdiesler commented 3 years ago
packages: */*.cabal

doesn't seem to work, but the Open in New Window thing does work for now.

lierdakil commented 3 years ago

This is not a simple fix. In fact, I'm questioning the feasibility of the fix. This would need some rather drastic changes to some dependencies, which I have my doubts will be accepted.

However, I've verified the cabal.project workaround and it works on my end; specifically, here's the diff:

diff --git a/futurelearn/cabal.project b/futurelearn/cabal.project
new file mode 100644
index 0000000..f44a24c
--- /dev/null
+++ b/futurelearn/cabal.project
@@ -0,0 +1 @@
+packages: */*.cabal

I figure this is a reasonable workaround for the time being. It needs to be documented though, as well as a bunch of other stuff.

As a heads-up, I'm transferring this issue to the relevant repo.

tdiesler commented 3 years ago

ok, thanks