Skip to content

Code action: switch to record syntax #4391

Closed
@guibou

Description

@guibou
Collaborator

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

My codebase is full of pieces of record that are constructed using "function" syntax. Something such as:

data Foo = Foo {
   count :: Int,
   name :: String
}

boz = Foo 10 "hello"

Describe the solution you'd like

I would like a code action available on Foo in boz which expand the syntax to record field syntax. Said otherwise, after usage, I would like:

boz = Foo 10 "hello"

to become:

boz = Foo { count = 10, name = "hello" }

Describe alternatives you've considered

Additional context

This can also be extended to other cases where record are used in "function" form, example for pattern matching:

biz (Foo a b) = ...

Could be turned to:

biz (Foo {count = a, name = b}

If you are interested and if the initial design is ok, I can give a try to the implementation.

Activity

michaelpj

michaelpj commented on Sep 4, 2024

@michaelpj
Collaborator

Definitely desirable!

I think this would be nice if it was done in combination with #4212, since it should be mostly the same code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @michaelpj@fendor@guibou

      Issue actions

        Code action: switch to record syntax · Issue #4391 · haskell/haskell-language-server