Adding Record-Dot-Syntax support to Haskell Language Server

This page serves as a record of the work I did for Google Summer of Code 2022. I want to thank the community at #ghc and #haskell-language-server for being so welcoming and helpful this summer. And a special super thanks to Michael Peyton Jones for mentoring me!

Over the summer I added record-dot-syntax support to the haskell language server.

Record-dot-syntax was a highly-requested feature that GHC introduced in version 9.2.0 with the OverloadedRecordDot language extension. For years users had been frustrated by Haskell’s conspicuous lack of support for namespacing features common in other languages. Haskell provided a limited form of namespacing with qualified imports, but using it to namespace field selectors tended to require hacky file structures. Record-dot-syntax aimed to fix that with ergonomic field selectors that use the syntax myrecord.somefield.

To unlock the true potential of this language feature, users should be able to “dot into” records as they edit, seeing the fields available to select. This was the main contribution of this project. Additionally, users expect the editor correctly report type information when they hover over records, so this was another important contribution.

I decided to split my work into two phases: adding support for hover information first, then adding support for completions. The reason was that it would be easier to add completion information once the type information is properly exposed.

Phase 1: Exposing type information on hover

Relevant issues and commits:

What hover type information looks like in VSCode

Phase 2: Adding completions

Relevant issues and commits:

What record completions looks like in VSCode