-
Notifications
You must be signed in to change notification settings - Fork 81
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
Setup ghcide for rules_haskell repository #1262
Conversation
Cool! I could successfully reproduce the setup as follows:
Then in another shell, because I didn't want to pull neovim's coc dependencies from nix; and used my system install instead: Video is a bit laggy because of the recording, but it's really smooth otherwise. In case things aren't working as expected:
|
Once this merged, don't forget to schedule a tweet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's awesome!
My only pain point is that setting this up is a bit involved. I'd really like this to be easier (as close to zero-config as can be). Though that's not a blocker for this PR and can be solved incrementally later
After a bit more testing it looks like hover only display the haddock documentation for the values that come from libraries bundled with GHC (so not from |
bf0cb60
to
7eaddfc
Compare
7aab355
to
ed233c1
Compare
90045a7
to
12198ba
Compare
This is now ready for review. I've updated the PR description to reflect the latest state. |
#!/usr/bin/env bash | ||
set -euo pipefail | ||
bazel build //:hie-bios --output_groups=hie_bios | ||
cat bazel-bin/hie-bios@hie-bios >"$HIE_BIOS_OUTPUT" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure where to put this, but I ran into some issues with targets building with -Werror
because ghcide forcibly sets some warnings (like missing-signatures), so the combination of both might lead to spurious errors. The common way out of this is that most hie bioses seem to filter out -Werror
or add -Wwarn
, and that's what I also did by added an echo -Wwarn
at the end of .hie_bios
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point, another way to deal with this is to add -Wwarn
to the toolchain's GHCi flags, e.g. https://github.com/digital-asset/daml/blob/a47c734401a70e5b9dd94cd9717a2192bc28c703/WORKSPACE#L382.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nvm, I see that the hie-bios output group doesn't include those. Though maybe it should.
Addressing review comment #1262 (comment)
docs/haskell-use-cases.rst
Outdated
Note, that if you are using Nix, then you may need to invoke ghcide within a | ||
``nix-shell``. | ||
Be sure to configure your editor to invoke the above wrapper script instead of | ||
another instance of `ghcide`. Also note, that if you are using Nix, then you | ||
may need to invoke ghcide within a ``nix-shell``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smelc I made the docs a bit more explicit regarding pointing the editor to the correct instance of ghcide
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Addressing review comment #1262 (comment)
I stumbled across a strange error with this on #1342 |
Addressing review comment #1262 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one minor comment but can be solved as a follow-up if needs be
Next, we need to hook this up to `hie-bios`_ using the `bios cradle`_. To that | ||
end, define a small shell script named ``.hie-bios`` that looks as follows:: | ||
|
||
#!/usr/bin/env bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is out-of-sync with the .hie-bios script in this repo.
I guess it's on purpose (to show a simple-but-working script in the docs), but maybe we could export the full-featured script as a bazel target and let the client-side .hie-bios script just be something like
#!/bin/bash
bazel run @rules_haskell//:hie-bios //:hie-bios
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed that was intentional to keep the documentation simple.
but maybe we could export the full-featured script as a bazel target
That's a very nice idea, thanks!
🎉 All dependencies have been resolved ! |
Verifies that the ghcide binary builds and can be executed. Does not test actual loading of sources into ghcide. Also ensures that ghcide is built during the build stage in CI.
Addressing review comment #1262 (comment)
The ghcide binary is built as a static binary and uses the static RTS. That means that GHCi's linker within ghcide will not look for dynamic libraries of the form `libHSfoo-ghc8.8.2.so`, but only for static libraries of the form `libHSfoo.a` (oddly also for `libHSfoo.so`). Closes #1342
The -pgm arguments contain spaces and need to be quoted for the REPL script. However, hie-bios expects unquoted arguments one per line of the hie-bios file.
Depends on #1350.
This configures
hie-bios
forghcide
forrules_haskell
.ghcide
as built bystack_snapshot
andhaskell_cabal_binary
to the repository. stack_snapshot build executable components #1304 will make this easier in the future.haskell_repl
target to determine GHC flags required for the REPL session..hie-bios
script to the repository that is picked up byhie-bios
'sbios
cradle. When executed that should write all GHCi flags to a file specified by theHIE_BIOS_OUTPUT
environment variable. See hie-bios README. Once multi-component support is implemented in ghcide this should become more flexible. See Multi Component haskell/ghcide#522 (comment)ghcide
and checks thatghcide --version
works. This is run on nixpkgs and bindist configurations.RunTests
that invokesghcide
on a target and checks if it can successfully determine the required GHC flags. This is only run onnixpkgs
configurations, sincerun-tests
is only executed there.ghcide
withrules_haskell
. The setup is still pretty involved, stack_snapshot build executable components #1304 will simplify it a fair bit. We may want to hold off wider announcement, e.g. a tweet, until this is merged.In order to make use of
ghcide
onrules_haskell
you need to configure your editor to use it. See setup instructions. For example, the following works for neovim with coc:.vim/coc-settings.json