dramforever/vscode-ghc-simple

could not find module error

traptw1thin opened this issue · 3 comments

Status

  • A workaround is available
  • A fix is written
  • A fix is released
  • The fixed version is on the marketplace.

  • Version of vscode-ghc-simple: v0.1.22
  • Version of VSCode:
  • Version of Haskell-related tools:
    • GHC:
    • Stack:
    • Cabal:

Steps to reproduce

the statement: import SomeModule is highlighted and it says:

Could not find module SomeModule' Use -v (or :set -v` in ghci) to see a list of the files searched for.

However, SomeModule.hs is in the same directory and the code compiles just fine. The full header of the file is, for instance:

module HW3 (module HW3, module SomeModule) where

import SomeModule

Workspace

GHC log

You should try to load your module in GHCI first, if you get it to work there then the extension will work too.

I'm having the same issue. I'm very new to Haskell so I'm 100% convinced that this is a user error on my part. Some pointers would be appreciated though! The import works fine when running stack ghci myfile.hs.

Setting replCommand to "stack ghci" fixes this, but creates new issue: I'm no longer getting type errors or warnings in the editor (still seeing syntax errors, hover info and types). Seems like setting replCommand makes GHCI run with different settings or something

@traptw1thin I discovered that (at least for my project) GHCi was starting in / which explains why my local modules weren't discovered. I was able to get around it with the following config in .vscode/settings.json:

{
  "ghcSimple.startupCommands.custom": [
    ":cd /<path-to-my-project>"
  ]
}

Might be worth a try!