Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

Could not load module ‘HaskellSay’ #1

Open
tdiesler opened this issue May 2, 2021 · 8 comments
Open

Could not load module ‘HaskellSay’ #1

tdiesler opened this issue May 2, 2021 · 8 comments

Comments

@tdiesler
Copy link

tdiesler commented May 2, 2021

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
Copy link
Contributor

lierdakil commented May 2, 2021

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
Copy link
Author

tdiesler commented May 2, 2021

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
Copy link
Contributor

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
Copy link
Author

tdiesler commented May 2, 2021

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
Copy link
Contributor

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
Copy link
Author

tdiesler commented May 3, 2021

packages: */*.cabal

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

@lierdakil
Copy link
Contributor

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.

@lierdakil lierdakil transferred this issue from atom-haskell/ide-haskell May 4, 2021
@tdiesler
Copy link
Author

tdiesler commented May 8, 2021

ok, thanks

@tdiesler tdiesler closed this as completed May 8, 2021
@lierdakil lierdakil reopened this May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants