stylish-haskell
stylish-haskell copied to clipboard
`records` rule will sometimes cause records to start violating `columns` parameter
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.
Yeah, the option should probably be the default (don't reformat the field if it will cause us to violate max columns).
The option to allow for multiline field types even if they don't go over the limit wouldn't be the worst thing either, if half the lines go over then it's probably more aesthetically pleasing to just have them all be multiline.