HLS/Visual Studio Code -- what's so great about it?

I don’t think the wordle videos are using HLS.

The reason I like HLS so much is that it just gives an IDE experience that at least I didn’t know how to get with Haskell before.

Say I want to write a new function foo. I might write a definition for foo, and then HLS will automatically suggest a type and actually add it to the code. If foo had e.g. an undefined somewhere in it, I can mouse over that to see its inferred type. Then I search that type in hoogle (no need to go to a browser, it’s integrated in vscode) and find that e.g. sortOn is the function I want. I then substitute undefined for sortOn but now a red underline appears and when I mouseover, it says that this function isn’t in scope. I hit ctrl . , and vscode automatically imports sortOn from Data.List.

If I do a case statement, wingman automatically completes it for me. If I have an hlint issue, like writing fmap a . fmap b instead of fmap (a . b), vscode corrects it for me. If I have unused variables, vscode tells me. If my type requires a language extension like RankNTypes, vscode tells me. These suggestions are really helpful for learning more about the type system.

If a type signature needs a constraint that it doesn’t have like Ord e => ..., vscode can automatically add it. When I need to refactor my code, and imports change, vscode makes that easy too. It also runs ghcid in the background, so the moment I change my code to introduce a type error, I know. No more cycles from recompiling, fixing and recompiling again.

But mostly, it’s super easy to set up, and so makes Haskell accessible to beginners.

Some problems I have with it (that I should probably post as issues):

  • crashes more than it should
  • imports of pattern synonyms and a few other things are broken
  • sometimes suggests importing a function from the same file, creating a circular import
1 Like