-
-
Notifications
You must be signed in to change notification settings - Fork 389
Linking issue with Template Haskell that depends on C code #365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Some more details: Apparently, this issue has to do with the TH code depending on C code, which means it must be built before compiling the TH module. It seems that HLS somehow messes up this ordering, whilst This issue also persists using an ubuntu VM via WSL2, which further indicates it's not a Windows problem. I also just noticed that, in the modules that don't (transitively) depend on this TH function executing (in particular, the module where the TH function is defined), hls does work! |
Minimal repro: https://github.com/tmcdonell/hls-bug |
There is no cradle in your repro. Could you please define one and test again? Test both with the Cabal and Stack cradles. For this to work, the C object needs to be listed in the flags provided by hie-bios for the cradle |
where with 'simple cradle' I mean an hie.yaml file containing What flags could list the C file? |
Maybe it will be fixed with TH full support: haskell/ghcide#836
The ghc flags that the component |
I don't think this would work right now, I think we need to compile the foreign files like this: |
This would need an issue in ghcide |
* Add a plugin type * Add a helper to construct codeAction values * Remove a redundant $
Any new insight on what needs to be done for this to work properly? HLS is still completely nonfunctional in any module that either directly or indirectly imports a module that uses calls Template Haskell code defined in some other module in a package that uses the FFI. In the example reported in the OP the particular module that exposes |
Are you talking about package part of cabal/hackage dependencies, or ones which are local to your project? |
These modules are all local to the project/package. If you were to move one of the modules that's causing issues from Accelerate to some other external library that links to Accelerate then import the module from there then there are no issues. |
If you want a temporary workaround for now, perhaps you use |
Without these stubs HLS wouldn't be able to provide completion in any module that directly or indirectly includes any of the 'Data.Array.Accelerate.Pattern.*' modules. haskell/haskell-language-server#365
That's a great idea! I've added some stubs, and now HLS works again as expected. 🎉 Of course it would be ideal if adding stubs/using the CPP wasn't necessary, but given that our use case is probably fairly rare and fixing it is likely also non-trivial this workaround works great for the time being. Thanks a lot! |
Without these stubs HLS wouldn't be able to provide completion in any module that directly or indirectly includes any of the 'Data.Array.Accelerate.Pattern.*' modules. haskell/haskell-language-server#365
Without these stubs HLS wouldn't be able to provide completion in any module that directly or indirectly includes any of the 'Data.Array.Accelerate.Pattern.*' modules. haskell/haskell-language-server#365
I'm suffering from this too. My project (many projects, in fact), use They only compile with Thus I get with HLS:
This bug is labelled as |
@wz1000 Were would that have to be done? |
Also, is there a non-CPP equivalent to |
Sorry the label is obsolete as the issue was created when ghcide lived in another repo. I wanted to mean hls was blocked on a ghcide change and i noted
But the issue was never created 😟 Removing the label as ghcide lives here now and it is where the fix mentioned by @wz1000 should be done |
Not sure if it would work for you use case but you can create a runtime check from a cpp one: usingGhcide :: Bool
#ifdef __GHCIDE__
usingGhcide = True
#else
usingGhcide = False
#endif |
@jneira I have made a draft PR to Could you have a look at it? It cannot use the So I'm determining it by reading an environment variable also called Do you agree with this approach? If yes, could you make HLS set this |
@jneira Just to confirm, that effort hasn't been started yet, right? Also, there might still be a tradeoff: Compiling C++ files can be very slow (e.g. up to 30 seconds if you include complex header files like from the
Sounds good! Are there env vars that already exist that I could use? |
no, it has not started afaik and to have a way to write code ghcide aware at runtime could have other uses (not sure if they will be clean ones though 😉)
I did a quick search and did not find anything but maybe @pepeiborra knows about some suitable env var |
I'm not aware of any env var that you can use to detect HLS currently. |
I am gonna close this issue as all compiler crashes seems to have the same root cause:
If any of you think the issue should not be included generically feel free to reopen it (with a brief explanation if possible) |
@jneira I think we have to re-open this one: I'm now on the much newer HLS in NixOS 23.05 which has the fixes from #365 (comment) in, but it is still required to do the env var based symbol stubbing for I believe this is because
is still the case. So I think we should make HLS set the env var as discussed in #365 (comment) and above, and that should close this issue. |
On Windows, when trying to use the VSCode plugin on accelerate. HLS works as expected on other codebases.
I get the following, identical, errormessage on the
Bool.hs
,Either.hs
,Maybe.hs
andOrdering.hs
files:All four of these files apply the TH function
mkPattern
from Pattern/TH.hs on these Prelude datatypes.As a result, it seems (looking at the verbose output in VSCode) that HLS always responds to queries in this package (hover, go to definition, etc), even unrelated to these patterns, with
null
or[]
.The text was updated successfully, but these errors were encountered: