ihp icon indicating copy to clipboard operation
ihp copied to clipboard

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

Open djfm opened this issue 4 years ago • 12 comments

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.

djfm avatar Jan 15 '22 15:01 djfm

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

zacwood9 avatar Jan 15 '22 15:01 zacwood9

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

djfm avatar Jan 15 '22 15:01 djfm

Could you please add your investigation to the issue on the HLS repo? https://github.com/haskell/haskell-language-server/issues/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.

zacwood9 avatar Jan 15 '22 16:01 zacwood9

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?

djfm avatar Jan 15 '22 16:01 djfm

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.

zacwood9 avatar Jan 15 '22 17:01 zacwood9

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.

djfm avatar Jan 15 '22 17:01 djfm

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 👍

mpscholten avatar Jan 16 '22 10:01 mpscholten

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 :/

djfm avatar Jan 16 '22 10:01 djfm

@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";
      };
  }

zacwood9 avatar Jan 16 '22 22:01 zacwood9

@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?

mpscholten avatar Jan 25 '22 19:01 mpscholten

Hi, sorry for the late reply, I'm unfortunately not proficient enough with Haskell to use it for my daily work yet :)

I've just re tried the creation of the default blog following the instructions from the website exactly: worked flawlessly and the HLS seems to be holding.

I've only been playing around with it for like 10 minutes but it would already have crashed 3 times before so I think we're good. HSX is working fine too now.

I've worked for years as a product manager so I always tend to assume people are interested in user feedback, so here's mine about the onboarding and first impressions on the product - feel free to ignore it:

On the plus side:

  • 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:

    • it's an excellent proof of the capabilities of the framework, so good idea
    • the generator is a very convenient way to discover features, very nice touch. That's very important imo since most people have no idea what Haskell is and nobody likes reading doc

Slight negatives:

  • 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

  • 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.

  • 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.

Well, nice work, I'm gonna try implementing a small work project with IHP to test it for good, I hope it performs the way I think it does!

On Tue, Jan 25, 2022, 20:55 Marc Scholten @.***> wrote:

@djfm https://github.com/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?

— Reply to this email directly, view it on GitHub https://github.com/digitallyinduced/ihp/issues/1317#issuecomment-1021554150, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALESEYWEOICWODFX3YBCV3UX353VANCNFSM5MBCTM4Q . You are receiving this because you were mentioned.eMessage ID: @.***>

djfm avatar Feb 02 '22 20:02 djfm

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!

mpscholten avatar Feb 04 '22 15:02 mpscholten