Skip to content

Throws errors with polysemy library installed #4762

@ianmelendez95

Description

@ianmelendez95

Edit: After more testing even with the semantic tokens off it has a problem, so nevermind the initial assessment, there is something wrong with the default configuration of HLS.

When I add polysemy to my cabal file, HLS completely breaks. If I remove polysemy there are no issues either.

Your environment

Which OS do you use?
MacOS

Which version of GHC do you use and how did you install it?
9.12.2 from ghcup

How is your project built (alternative: link to the project)?
https://github.com/ianmelendez95/nube built using cabal
I've created a branch 'hls-polysemy-issue-example' that has the commit "ISSUE INTRODUCED - added polysemy to project" showing exactly what change is necessary to introduce the issue
https://github.com/ianmelendez95/nube/tree/hls-polysemy-issue-example

Which LSP client (editor/plugin) do you use?
vscode-haskell

Which version of HLS do you use and how did you install it?
2.12.0.0 from ghcup

Have you configured HLS in any way (especially: a hie.yaml file)?
No

Steps to reproduce

  • Checkout the hls-polysemy-issue-example branch in the nube repo.
  • Open one of the .hs files, for example app/JS/Transpile.hs
  • Make an edit
  • Output will include a flood of Error messages that requests failed.
  • (To "fix"), checkout the second most recent commit, which removes the 'polysemy' library from the project
  • Output will not include errors, and HLS will start to work correctly

Expected behaviour

  • Should not log any output errors and files will have proper warning/error highlighting etc.

Actual behaviour

  • Output will include a flood of Error messages that requests failed.
  • Error/warning highlights will not work, all files are highlighted at the top with a red error due to the underlying HLS errors calling cabal

Debug information

hls-polysemy-errors.log

  • Output includes errors like

[Error - 4:17:46 PM] Request textDocument/codeLens failed.
Message: moduleName: Rule Failed: GhcSession
Code: -32803

  • When I change the server trace to 'verbose', I noticed these 'published diagnostics'

Failed to parse result of calling cabal
Failed command: cabal '--builddir=/Users/ianmelendez/.cache/hie-bios/dist-nube-db4b70f404916b4acbbdb7cf59ce273a' v2-repl --with-compiler /Users/ianmelendez/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /Users/ianmelendez/.cache/hie-bios/ghc-pkg-266a8b3edaaec456837eb0c63da1227d /Users/ianmelendez/haskell-projects/nube/app/JS/Parse.hs
Build profile: -w ghc-9.12.2 -O0
In order, the following will be built (use -v for more details):

  • nube-0.1.0.1 (interactive) (lib) (first run)
    Preprocessing library for nube-0.1.0.1...
    GHCi, version 9.12.2: https://www.haskell.org/ghc/ :? for help
    [1 of 7] Compiling JS.Syntax ( app/JS/Syntax.hs, interpreted )
    [2 of 7] Compiling JS.Parse ( app/JS/Parse.hs, interpreted )
    [3 of 7] Compiling Gen.CF ( app/Gen/CF.hs, interpreted )
    [4 of 7] Compiling Gen.Lambda ( app/Gen/Lambda.hs, interpreted )
    [5 of 7] Compiling JS.Transpile ( app/JS/Transpile.hs, interpreted )
    [6 of 7] Compiling Util.Aeson ( app/Util/Aeson.hs, interpreted )
    [7 of 7] Compiling Compile ( app/Compile.hs, interpreted )
    Ok, 7 modules loaded.
    ghci> Leaving GHCi.

app/JS/Syntax.hs:75:1: warning: [GHC-62161] [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In an equation for ‘stmtText’:
Patterns of type ‘Stmt’ not matched: SAssign _ _
|
75 | stmtText (SConst var rhs) = "const " <> var <> " = " <> exprText rhs <> ";"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

app/JS/Parse.hs:71:5: warning: [GHC-40910] [-Wunused-local-binds]
Defined but not used: ‘parameters’
|
71 | parameters =
| ^^^^^^^^^^

app/JS/Parse.hs:208:1: warning: [GHC-40910] [-Wunused-top-binds]
Defined but not used: ‘space1'’
|
208 | space1' = takeWhile1P (Just "whitespace") isSpace
| ^^^^^^^

app/JS/Transpile.hs:11:13: warning: [GHC-40910] [-Wunused-top-binds]
Defined but not used: data constructor ‘Cont’
|
11 | data Cont = Cont [S.Stmt]
| ^^^^^^^^^^^^^

app/JS/Transpile.hs:14:24: warning: [GHC-40910] [-Wunused-matches]
Defined but not used: ‘stmts’
|
14 | splitStmtContinuations stmts = undefined
| ^^^^^

Process Environment:
HIE_BIOS_GHC: /Users/ianmelendez/.ghcup/bin/ghc
HIE_BIOS_GHC_ARGS: -B/Users/ianmelendez/.ghcup/ghc/9.12.2/lib/ghc-9.12.2/lib

However, I ran the cabal command myself before and after installing polysemy and the output is identical, so I suspect it's a symptom and not the issue.

Attempted fixes

I installed/configured everything recommended by the polysemy library. That includes the GHC options they recommend, including the compiler plugin with the polysemy-plugin library, as well as the default-extensions settings. None of those had any impact on the observed errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs triagetype: 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