Skip to content
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

Haskell Language Server dies upon opening a file containing hsx in VSCode #1317

Open
djfm opened this issue Jan 15, 2022 · 12 comments
Open

Haskell Language Server dies upon opening a file containing hsx in VSCode #1317

djfm opened this issue Jan 15, 2022 · 12 comments

Comments

@djfm
Copy link

djfm commented Jan 15, 2022

Hi, sorry if this is not the appropriate place to report this issue, I'm not very familiar with the Haskell ecosystem (yet, hopefully).

On a pristine installation of IHP and after creating the test project, when I open it with vscode (with the correct extensions installed), I have intellisense working without issues as long as I don't open a file that uses hsx or references one that uses hsx.

But as soon as I open a file containing hsx or referencing one that contains hsx, it seems that hls becomes unresponsive or dies: no more messages in the debug console and no more intellisense.

It recovers if I close all the files containing hsx and manually restart hls. This is very annoying, I really wanna try and use IHP more but I don't feel brave enough to go without intellisense.

VSCode: 1.63.2
IHP: rev = "1902ac00654a77b3c9adab4a5326f4f441ccb0ac"

EDIT: As I wrote below, I "solved" it by uninstalling the system-wide GHC I had. Doesn't sound like the "right" solution but that worked for me.

EDIT 2: Actually not solved, need to restart HLS very often.

@zacwood9
Copy link
Collaborator

What OS are you running? This issue has been seen before on Linux but hasn't been a problem on macOS so far, so just want to confirm

@djfm
Copy link
Author

djfm commented Jan 15, 2022

Ubuntu 21.10.

I'm investigating, it definitely looks like it has something to do with the QuasiQuotes extension.

I'm getting different results with:

  • base scenario: hsl seems stuck, status message "processing 20/26"
  • {-# LANGUAGE QuasiQuotes #-} added to the 2 files containing hsx: no more "processing..." stuck, intellisense works unless I open a file containing hsx
  • with the file hie.yaml removed: hsl doesn't get stuck and seems responsive but no intellisense appears

@zacwood9
Copy link
Collaborator

Could you please add your investigation to the issue on the HLS repo? haskell/haskell-language-server#2340

There was some movement here but seems to have stalled. Hopefully we can get this moving again because this is a serious blockers for newcomers.

@djfm
Copy link
Author

djfm commented Jan 15, 2022

I know, I'm a newcomer and I'd really hate to give up because of IDE support.

Will post my findings once I'me more sure about them and after further testing.

If I can't get it to work with vscode, is there another recommended setup that provides top notch intellisense?

@zacwood9
Copy link
Collaborator

Thanks for posting in the thread. Reporting issues like this to the language server is a crucial step in getting the tooling to where it needs to be to provide a good experience for new developers.

The issue is not with vscode here, it's with the haskell-language-server so I don't think you'll get a better auto-complete experience moving away from vscode.

Haskell traditionally has had rather poor support in terms of an auto-completion based IDE, but there are other tools that I and many others use instead of a language server. The most useful and a must-have IMO is hoogle, which allows you to search for functions by name and type signature and view documentation for them and the packages they belong to. You can play with it at https://hoogle.haskell.org.

The best part is you can setup a local hoogle which contains all the packages you have installed in your project, including IHP. Checkout this section in the docs for how to do that.

Another great tool is ghcid which runs your project in the GHCI REPL, reporting any errors and warnings on every save. There is a vscode package which uses this to provide inline error highlighting as well.

Haskell is just now catching up to some other languages in terms of developer tooling like language servers. There has been tons of progress made over the past two years but unfortunately, as you have experienced, it still isn't quite there yet to be usable on every project. Hopefully these issues will be fixed soon but in the meantime, I would encourage you not to give up on the language and try some of these other tools. They have served us well for many years, and although they are different than a normal language experience, you can still have very powerful and efficient workflows with them.

@djfm
Copy link
Author

djfm commented Jan 15, 2022

Thank you, I will have a look at hoogle and ghcid!

Yes, the tooling around Haskell sucks :/ I used to use Leksah back in the days, it was pretty cool, but now that it doesn't seem very much maintained and now that Ubuntu does not package it any more I gave up with it...

This is a pity, because I believe there is a huge opportunity for Haskell in this period:

  • the world has discovered that types are a good idea thanks to things like TypeScript making it not painful and relatively easily adopted
  • The world has discovered that immutability offers a lot of advantages (thanks to React). They might not understand why, but people are more and more willing to write pure code
  • the best contender I see for web development is TypeScript but the tooling around it is such an insane nightmare (and I say that being actually pretty versed in configuring modern web TS projects) that I think many people would consider a switch if the tooling in Haskell were truly nice

Until it works in VSCode, I don't think colleagues will use.

SOLVED: I found a "solution": uninstalling the system-wide GHC fixed the issue for me. I now have full intellisense in vscode even in hsx files! Very eager to start trying IHP out!

EDIT: After further testing, HLS keeps randomly crashing so this is not actually solved.

@mpscholten
Copy link
Member

This is a pity, because I believe there is a huge opportunity for Haskell in this period:
the world has discovered that types are a good idea thanks to things like TypeScript making it not painful and relatively easily adopted
The world has discovered that immutability offers a lot of advantages (thanks to React). They might not understand why, but people are more and more willing to write pure code
the best contender I see for web development is TypeScript but the tooling around it is such an insane nightmare (and I say that being actually pretty versed in configuring modern web TS projects) that I think many people would consider a switch if the tooling in Haskell were truly nice

Yes! :) You kind of independently discovered the "secret" idea behind IHP. Here's a slide from a past IHP meetup:

image

We'll get there 🚀

Until it works in VSCode, I don't think colleagues will use.

Agree 👍 we really need to make sure that this works better.

SOLVED: I found a "solution": uninstalling the system-wide GHC fixed the issue for me. I now have full intellisense in vscode even in hsx files! Very eager to start trying IHP out!

Glad it's working now. Please report back if you see more problems 👍

@djfm
Copy link
Author

djfm commented Jan 16, 2022

Thanks for sharing the slide, very relevant indeed.

Unfortunately as I said in my second edit the victory was short-lived: the HLS randomly crashes after a while, making the devX with VSCode extremely painful.

But this doesn't seem to be specific to IHP as it happens in vanilla cabal projects too :/

@zacwood9
Copy link
Collaborator

@djfm could you try with HLS compiled with dynamic linking? This solved the issue for me.

Simply change your Config/nix/nixpkgs-config.nix file to the following:

# See https://ihp.digitallyinduced.com/Guide/package-management.html
{ ihp, additionalNixpkgsOptions, ... }:
let
  haskellLib = (import <nixpkgs> {}).haskell.lib;
in
  import "${toString ihp}/NixSupport/make-nixpkgs-from-options.nix" {
      ihp = ihp;
      haskellPackagesDir = ./haskell-packages/.;
      additionalNixpkgsOptions = additionalNixpkgsOptions;
      manualOverrides = self: super: {
        haskell-language-server = haskellLib.appendConfigureFlag
            super.haskell-language-server "--enable-executable-dynamic";
      };
  }

@mpscholten
Copy link
Member

@djfm IHP v0.18 was released today with the --enable-executable-dynamic flag mentioned by zac enabled by default. Could you update to the latest version and report back if the situation has improved?

@djfm
Copy link
Author

djfm commented Feb 2, 2022 via email

@mpscholten
Copy link
Member

Thanks a lot for your feedback! Very interested in feedback, your guess is correct :)

  • coming from TypeScript with all the insane toys that go along with it my
    first impression creating an IHP project is that of a breath of fresh air
    and overall cleanliness

❤️

  • I'm not expecting I'm gonna use the web IDE / generator much (but who
    knows) but:

Give them a try :) Everyone is always not a big fan of this at first, but once you get used to them you might start to wonder why other frameworks don't have this. It really helps with discoverability of features in IHP.

  • the GitHub page doesn't provide installation instructions (just a video I
    think, didn't watch it), that's not very standard, requires additional
    efforts probably causing some user drop off

Good point. Will add instructions and links to the Guide there 👍

  • since the installation is so easy, maybe incorporating some more
    information about what's going on could be beneficial while not hurting the
    UX, like "nix is the equivalent of XXX if you're used to YYY". Remember
    that you're targeting people who most likely come from totally different
    universes.

Good point 👍 also created a ticket for this.

  • I did not understand very well how to configure the nix extension at
    first and had errors everywhere, I had to re select "default.nix" and
    reload. No big deal but not everyone would figure it out I guess.

Also good point. We will update the docs according to make this more visible.

Thanks again for your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants