stylish-haskell icon indicating copy to clipboard operation
stylish-haskell copied to clipboard

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

Open tysonzero opened this issue 2 years ago • 2 comments

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.

tysonzero avatar Apr 15 '22 00:04 tysonzero

Yeah, the option should probably be the default (don't reformat the field if it will cause us to violate max columns).

jaspervdj avatar Apr 15 '22 06:04 jaspervdj

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.

tysonzero avatar Apr 16 '22 05:04 tysonzero