Skip to content

Can't find project modules in test/Spec.hs until I restart VSCode  #1909

Closed
@sekunho

Description

@sekunho

Your environment

Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:

I don't know how to run this in VSCode.

Which OS do you use:
NixOS 21.05

Which lsp-client do you use:
VSCode's official hls plugin

Describe your project (alternative: link to the project):
I'm using stack. Following the simple haskell handbook project.

resolver: lts-17.10
packages: [.]
nix:
  enable: true
  packages: [ zlib ]
name: quad

default-extensions:
  - BlockArguments
  - DeriveAnyClass
  - DeriveGeneric
  - LambdaCase
  - NoImplicitPrelude
  - OverloadedStrings
  - StrictData

dependencies:
  - aeson
  - async
  - base
  - butcher
  - hslogger
  - http-client
  - http-conduit
  - http-types
  - network
  - record-hasfield
  - rio
  - scotty
  - serialise
  - stm
  - time
  - typed-process
  - wai-cors
  - yaml

ghc-options:
  - -F -pgmF=record-dot-preprocessor

library:
  source-dirs: src

executables:
  quad: 
    main: Main.hs
    source-dirs: app
    ghc-options:
      - -threaded
      - -rtsopts
      - -with-rtsopts=-N
    dependencies:
      - quad

tests:
  quad-test:
    main: Spec.hs
    source-dirs: test
    ghc-options:
      - -threaded
      - -rtsopts
      - -with-rtsopts=-N
    dependencies:
      - quad
      - hspec

Contents of hie.yaml:
N/A

Steps to reproduce

The project is structured this way:

image

Then when trying to import the Docker module, HLS complains about how it can't find it.

image

What's weird is that previously, it couldn't find the Core module. Not sure what changed, and weird that this time it doesn't know what the Docker module is even if it's just in the same folder as Core.

Expected behaviour

It's supposed to import the project's modules just fine in the test.

Actual behaviour

It can't find the modules properly.

Include debug information

So I tried following the instructions, and restarted VSCode. Now it seems to detect it normally. But does it mean I have to restart VSCode every time I add a new module? Weird that when I tried restarting the LSP server, it still had the same issue so I had to restart the entire VSCode for it to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    build tool: stackos: nixostype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions