haskell / haskell/stylish-haskell

`records` rule will sometimes cause records to start violating `columns` parameter

Open
#396 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Haskell
Stars
1k
Forks
153
PR merge metrics
No merged PRs in 30d

Description

With the following config:

```
steps:
- records:
equals: "same_line"
first_field: "indent 4"
field_comment: 2
deriving: 4
via: "same_line"
break_enums: true
break_single_constructors: false
curried_context: false
columns: 100
```

It converted our existing (desired) code:

```
data Api r = Api
{ _listDocuments :: r :- "list-documents"
:> QueryParam' '[Required] "id" ThreadId
:> Get '[JSON] [Document0]
, _uploadDocument :: r :- "upload-document"
:> QueryParam' '[Required] "id" DocumentId
:> ReqBody '[JSON] MisoString
:> Post '[JSON] ()
} deriving (Generic)
```

To:

```
data Api r = Api
{ _listDocuments :: r :- "list-documents" :> QueryParam' '[Required] "id" ThreadId :> Get '[JSON] [Document0]
, _uploadDocument :: r :- "upload-document" :> QueryParam' '[Required] "id" DocumentId :> ReqBody '[JSON] MisoString :> Post '[JSON] ()
}
deriving (Generic)
```

It would be nice if there was an option to leave the former alone.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the records rule and the columns-width handling using the configuration and before-and-after examples in this issue. Determine how the rule can preserve the existing multiline layout without violating the columns setting, then add coverage for this configuration and verify the formatted output remains within the requested behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.