haskell / lsp

Haskell library for the Microsoft Language Server Protocol
360 stars 89 forks source link

Generate types from the metamodel (attempt 2) #478

Closed michaelpj closed 1 year ago

michaelpj commented 1 year ago

This is a redone version of https://github.com/haskell/lsp/pull/458. That foundered on the use of TH, in particular I really struggled to get it to work on multiple versions of GHC. This version is similar, but takes a much more basic approach of just building up big strings for Haskell modules. It works okay; it's much easier to debug; it's more reliable; documentation works better; and it compiles faster. So I think we can go with this.

michaelpj commented 1 year ago

I'm also considering moving to generic-lens and dropping the lens generation, but I'll do that in a follow up PR if so.

michaelpj commented 1 year ago

Of interest to @thomasjm and @joyfulmantis perhaps.

michaelpj commented 1 year ago

Addressed comments, and added NFData instaces.

thomasjm commented 1 year ago

Possible dumb question--I wanted to build the Haddocks for this but ran into trouble. I added a simple Stack file (see below) and was able to build the branch.

However, when I run stack haddock --open, the generated stuff doesn't seem to be there. The only modules I see are Language.LSP.MetaModel.*. Am I missing something?

# stack.yaml
resolver: lts-19.33
packages:
- lsp-types
extra-deps:
- row-types-1.0.1.2
michaelpj commented 1 year ago

Hmm, it works for me with cabal haddock. I don't know if stack is doing something funny here? You shouldn't see the metamodel types at all, those are from a sub-library that isn't the main one.

michaelpj commented 1 year ago

Okay, let's merge this to make iteration easier. It looks like the upgrade in HLS is going okay, so I don't think we'll need to back this out and we can tweak it in master.

thomasjm commented 1 year ago

I've been converting my projects to lsp-types-2.x and I just wanted to say this new version is really great, very regular and easy to work with. Awesome work @michaelpj !

michaelpj commented 1 year ago

Hooray, I'm glad it's good to use :)

ChrisPenner commented 11 months ago

Stoked with the quality of this lib! It's making development of the unison LSP SO much easier 😁

Excited to have access to new LSP features quickly 🙌🏼

Thanks for all your hard work!