haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.64k stars 354 forks source link

Inlay hints for record wildcards #4211

Closed michaelpj closed 1 week ago

michaelpj commented 4 months ago

Is your enhancement request related to a problem? Please describe.

Record wildcards implicitly bind the record field names. We can use inlay hints to display that information explicitly, and triggering it could insert an explicit binding for the field.

Describe the solution you'd like

f Foo{...}

becomes

f Foo{<hint>bar,</hint><hint>baz,</hint>...}
michaelpj commented 2 months ago

A few things to think about:

  1. Do we want to insert field assignations that use NamedFieldPuns or not? I would say "yes", since it's the closest to what RecordWildcards does (it also relies on the field name matching the variable). So we would generate Foo{bar} rather than Foo{bar=bar}. This would require us to add the NamedFieldPuns pragma, potentially.
  2. Do we want to have one hint for making the whole thing fully explicit, or one hint per field? I think people might want either, so we should see if we can make it possible to do both gracefully. Otherwise we might have to pick one.
  3. RecordWildcards can appear in both expressions and patterns, we should support both.