-
Notifications
You must be signed in to change notification settings - Fork 81
Suggestion: improved process for language server setup #1489
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
Thank you for raising this! I agree the docs on IDE integration could definitely use improvement. As they say at the beginning, the current status is preliminary. I'd be very happy to take PRs on this! I don't think I'll have time to work on hls support myself in the foreseeable future.
Agreed, the docs should be updated from ghcide to hls.
Yes, this should be clarified in the use-case docs as well. The from_binary and from_source attributes are documented in the API docs. Just to clarify, the from_source and from_binary attribute don't directly reference targets, instead they are patterns to match on targets included in the transitive closure of
Could you clarify what motivates this query and how it works? Another note,
Could you clarify how you set these attributes and what values you set them to?
Similar to above, it's not clear to me where you can define these global patterns.
Agreed, requiring a single global repl for hls integration is not what we want. The historical reason is that multi-cradle support was not available at the time when this was developed. See related discussion here. Relatedly, I experimented with generating hie-bios files on-the-fly directly from the aspect in the past, see here. Unfortunately, I ran out of time on these experiments. An issue I encountered in that approach, that may be relevant here, was that ghcide (this was not on hls, yet) ended up creating too many overlapping ghc sessions, which ate up too much memory.
Build failure should only be an issue for
I don't understand this point. |
Thank you for reading this and commenting, let's address your questions.
Yes, thank you for the clarification. I'm using them indeed as pattern, for example, I do have
You are right about your understanding of the query. Let me detail it:
Another really good solution is:
If ensures that the shortest path is selected with
No. I just tried
I was unclear. The
Well, some
I was unclear, I meant that, afaik, you cannot have a "global" repl which references Thank you for the different link to your experimentation, I'll have a look. |
Thanks for clarifying and explaining the query.
Just a hunch: Are these missing libraries coming from external repositories? For the hie-bios file we don't prefix command line library search paths with the execroot. This works fine for local library targets, but external libraries will have entries such as
That should work, |
No, that's actually not missing libraries, but missing symbols. |
Good news, I did some progress reading haskell/haskell-language-server#1160 (comment) , compiling my |
Hello. Any progress on this? |
What's the status here? Is this only a docs issue, or are there some improvements we could make towards better compatibility with HLS? |
Hi, I'm also interested in this. Currently I'm replicating Bazel in stack just for Language Server Support. Anyway we can help? It seems like @guibou did all the work already |
@tonicebrian sorry, I won't help you more here, at work I've stopped using bazel for HLS a few months ago and last week I've merged the removal of bazel from the codebase at work. |
Ups, if you don't mind could you explain why did you abandon bazel? I'm doing the reverse path because I think it will help me in my polyglot purescript+Haskell project. I don't want to find out 6 months in the future that it wasn't the right choice. With what did you swap bazel? |
@tonicebrian Really long story short. Bazel had never worked for me, it had never answered any of its promise of being simple, fast, robust, composable, ... (lot of buzzwords). We swapped bazel to a builder written integrally in nix. We got the same features in 600 lines of nix and got a reproducible build, remote build, remote cache, as well as feature that bazel was not providing (as far as I know) without patching it or the rulesets. In a first company, I started experimenting with nix as a build system and I had promising results, but I was not in a position to propose a switch (I was hired as a bazel consultant). In another company, I joined when bazel was already the build system of choice. Considering my bazel "experience", other developeres asked me if we should switch away from bazel. I decided to not, the situation was acceptable and I did not wanted to be involved much in build system. However, after one year, I had to fix / workaround a lot of problems similar to what happened in the previous company, that the idea to move away from bazel reappeared. Things accelerated recently after we spent a few days tracking a numerical error in simulation code which was actually due to an hermeticity problem in bazel (in short, bazel is using the system library loader in its test runner, which had impacts on our numerical code). I then restarted the nix experiment. It took me a day to write a POC in order to push binaries built with nix in production. We then decided that we'll prioritize the transition Do I recommend this approach? It depends. The current benefit is that things are working as intended. The main drawbacks are that nix have slower evaluation time (no-op build is ~1.5s), which is not a problem for us, and that we have a super specific piece of software that nobody else than me and a few colleague understand. Is that a problem? Yes. Is that worse than the 3k lines of bazel code + 5 forks of ruleset + 30 bugs open in our bugtracker, I don't know. Would this approach have been possible if I had not fighted 4 years with bazel, definitely no, because I acquired a lot of knowledge about build system, build, link, ghc, gcc, python, ... and how theses stuff are interacting together. Sorry, my answer is mostly feelings and buzzwords (we may not have the same definitions of what "composable" or "robust" means). I would be able to develop with countless examples of what nightmares I had to fight with bazel, and unfortunately I don't have enough feedbacks on the new nix based build system to comment. Maybe we'll go back to bazel in a few month, who knows (Note that our nix build system uses In short, try bazel. If it works for you, be happy. If not, don't hesitate to move to something else. |
Thanks for the thorough response, I've just realised that I asked you same thing in Twitter a couple of weeks before without noticing that both avatars were the same person 😀 My use case is server in Haskell and frontend in purescript with some code generation for DTOs and client calls, and lots of microservices. That was the reason for going for bazel: multilanguague, dependencies between different language artifacts and remote caching. BUT |
I'm configuring
haskell-language-server
on a huge codebase. I do have many problems with the approach currently documented in https://rules-haskell.readthedocs.io/en/latest/haskell-use-cases.html#configuring-ide-integration-with-ghcide.I open this ticket in order to describe a different approach which mostly only impact documentation. Based on the result of the discussion, I could open a documentation PR.
First of all, I do have a huge codebase, with many Haskell packages, depth dependency tree. I also have build time generated Haskell code, and dependencies on many shared library built in different languages. I'm not aware of a more complex codebase using rules_haskell.
The documentation proposes to set a global
haskell_repl
which references all thehaskell_library
of the repository. The documentation does not document it, but you may have two solutions to references your libraries:from_source
, each Haskell module will be loaded from source. This solution does not scale for me, haskell-language-server is taking hours (and lot of RAM) in order to start.from_binary
, the packages linked in the repl will be first compiled by bazel and then added to the build information as-package
. This solution works for me, however it forces the user to wait for a full build of the codebase, which takes more than an hours or a quarter of hour if the user does have a fast remote cache access.bazel query
) in order to generate theBUILD
file for this repl. One problem was that some targets are failing, for some reasons, so we had to tag all of our failing target to ensure that they won't end in the repl.I tried a different approach than with success. Instead of building a global repl, I'm using a repl associated with an haskell_library which uses the file.
The
hie-bios
file does accept the path to the file being checked as first argument. I'm then using the followingquery
:where
FILEPATH
is the path to the file provided by HLS, and@repl
is my repl attached to eachhaskell_library
orhaskell_binary
.There is a few positives points with this approach:
from_binary
on the repl without forcing the rebuild of the full codebase.from_source
, it is way faster because it does not need to evaluate 1000 Haskell filesfrom_binary
andfrom_source
for each repl, that I can tune.What are your thoughts about this approach? I can update the rules_haskell documentation with it if you think that's a good idea.
Haskell language server
Unrelated note, I'm using
haskell-language-server
instead ofghcide
as depicted in the documentation. I have no special problem with it, except://third_party/hackage:lens
and//my/project:lens
which shares the same package namelens
). This problem appears less with the approach I just depicted.PATH
.haskell-language-server
does not find theghc
used by my project (thisghc
is provided bynixpkgs_package
in bazel). I had to write a wrapper for that.Considering that
ghcide
is now deprecated in favor ofhaskell-language-server
, I propose to update the documentation to recommendhaskell-language-server
instead.The text was updated successfully, but these errors were encountered: