hackworthltd / primer

A pedagogical functional programming language.
GNU Affero General Public License v3.0
13 stars 1 forks source link

HLS multi-component bug in primer-service and primer-test #181

Open georgefst opened 2 years ago

georgefst commented 2 years ago

(Just tracking this here in case anyone bumps in to it, and so that I've got a record of what the issue is for when I inevitably hit it again.)

If we load primer/primer-service/exe-server/Main.hs in to an editor running Haskell Language Server, we'll see a bizarre error in runDB:

Couldn't match type 'Primer.Database.Op' with 'Primer.Database.Op'

This is an instance of https://github.com/haskell/haskell-language-server/issues/1370.

Workaround: load some module from lib:primer-service in to the editor. e.g. primer-service/src/Primer/Server.hs (EDIT: and one from primer-selda e.g. primer-selda/src/Primer/Database/Selda.hs). This may take a few seconds for HLS to re-initialise with the new component, but it should resolve the error.

dhess commented 2 years ago

So does this mean we're doing something wrong at Haskell/Cabal level with our dependencies, or is this purely an HLS issue?

georgefst commented 2 years ago

So does this mean we're doing something wrong at Haskell/Cabal level with our dependencies, or is this purely an HLS issue?

I'm pretty certain this is purely an HLS issue. Although I wasn't sure when I started investigating. Given there's nothing we can actually do on our end, would you prefer this closed? It would still serve as a useful record.

dhess commented 2 years ago

Nah, let's track the upstream issue. It turns out that GitHub recently added a feature that does it automatically, so long as you format it something like this:

(Actually it seems the automatic tracking label on the upstream repo only works if you put the checkbox + link in the original post? ~Can you put it there and see?~ edit heh, you beat me to it :) )

georgefst commented 2 years ago

That's pretty cool. I've edited the OP.

georgefst commented 1 year ago

Unfortunately, #625 has made us considerably more vulnerable to this. Fix is essentially the same - load a module from primer-hedgehog (e.g. TestM) in to the editor if seeing these sorts of errors in primer-test.

georgefst commented 1 year ago

For the record, until this is fixed upstream, my fix is to load one file from each component in to VSCode:

code  \
  primer/src/Primer/Core.hs \
  primer/gen/Primer/Gen/Core/Raw.hs \
  primer/testlib/Primer/Test/Util.hs \
  primer/test/Test.hs \
  primer-api/src/Primer/API.hs \
  primer-api/gen/Primer/Gen/API.hs \
  primer-api/testlib/Primer/API/Test/Util.hs \
  primer-api/test/Test.hs \
  primer-service/src/Primer/Server.hs \
  primer-service/exe-server/Main.hs \
  primer-service/exe-client/Main.hs \
  primer-service/exe-openapi/Main.hs \
  primer-service/test/Tests/OpenAPI.hs \
  primer-selda/src/Primer/Database/Selda.hs \
  primer-selda/testlib/Primer/Database/Selda/Test/Util.hs \
  primer-selda/test/Test.hs \
  primer-benchmark/src/Benchmarks.hs \
  primer-benchmark/test/Main.hs \
  primer-benchmark/bench/Main.hs \

I'm sure this can be adapted for other editors.