Single long line when doing pattern matching to extract record fields #268

Open
opened 2019-11-28 03:17:59 +01:00 by zzantares · 1 comment
zzantares commented 2019-11-28 03:17:59 +01:00 (Migrated from github.com)

Hello, I'm just taking brittany out for a spin for the first time, it's a great work! but one thing I note does not work (I doubt is the desired result) is when doing pattern matching to extract fields from a record, I have enabled NamedFieldPuns extension, and formats like this:

  let
    LongRecordFields { longRecordFieldsOne, longRecordFieldsTwo, longRecordFieldsThree, longRecordFieldsFour, longRecordFieldsFive }
      = longRecordFields

That makes a very long line, I would rather prefer it to be formatted like this:

  let LongRecordFields
        { longRecordFieldsOne
        , longRecordFieldsTwo
        , longRecordFieldsThree
        , longRecordFieldsFour
        , longRecordFieldsFive
        } = longRecordFields

Is this possible to do? If not, what do you think? it could be added or the current behavior is the desired one?

Hello, I'm just taking `brittany` out for a spin for the first time, it's a great work! but one thing I note does not work (I doubt is the desired result) is when doing pattern matching to extract fields from a record, I have enabled `NamedFieldPuns` extension, and formats like this: ```hs let LongRecordFields { longRecordFieldsOne, longRecordFieldsTwo, longRecordFieldsThree, longRecordFieldsFour, longRecordFieldsFive } = longRecordFields ``` That makes a very long line, I would rather prefer it to be formatted like this: ```hs let LongRecordFields { longRecordFieldsOne , longRecordFieldsTwo , longRecordFieldsThree , longRecordFieldsFour , longRecordFieldsFive } = longRecordFields ``` Is this possible to do? If not, what do you think? it could be added or the current behavior is the desired one?
lspitzner commented 2019-11-28 21:08:17 +01:00 (Migrated from github.com)

Thanks!

I agree, and your preferred formatting looks good to me. We just have not come around to implementing anything in this direction, because patterns can appear in so many different places, and inventing proper layouts for some of them is mildly tricky.

See #143.

But your let example is relatively easy. Might be possible to implement something for let/where, but leaving the more complex contexts of function argument patterns, case, guards (ViewPatterns) etc. for later?

I'll think on this.

Thanks! I agree, and your preferred formatting looks good to me. We just have not come around to implementing anything in this direction, because patterns can appear in so many different places, and inventing proper layouts for some of them is mildly tricky. See #143. But your `let` example is relatively easy. Might be possible to implement something for let/where, but leaving the more complex contexts of function argument patterns, case, guards (ViewPatterns) etc. for later? I'll think on this.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: hexagoxel/brittany#268
There is no content yet.