Skip to content

HLS seems to require a library stanza in the cabal file #3932

Open
@Rotaerk

Description

@Rotaerk

Environment

OS: NixOS
GHC Version: 9.4.8
Cabal Version: 3.10.2.1
HLS Version: 2.4.0.0

Everything is installed via a nix flake. Here is my project at the time of issue submission: https://github.com/Rotaerk/vulkanSandbox/tree/85d04fd4a834000cb47a7992207f8c74c5028428

What's wrong?

Within the repository root, I run nix develop, which brings cabal, ghc, and HLS among other things into my path. I navigate into the VulkanSandbox directory, and run haskell-language-server-wrapper. When I do, it discovers all 14 of my source files, but fails to load every one, indicating that I need to add them to other-modules or exposed-modules in the cabal file. But they are already there.

The cabal file only has two stanzas: a common and an executable. I noticed that if I change the executable stanza into a library (and removed main-is), suddenly HLS is able to load the source files.

I also noticed that it works if I rename the executable stanza to VulkanSandboxExe, and then add a library stanza to it, such as:

library
  import: common

Note: I tested and confirmed that renaming the executable stanza alone was not enough.

Did I miss something in the HLS documentation about requiring library stanzas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions