Skip to content

Comment placement on then/else branches #998

@mitchellwrosen

Description

@mitchellwrosen

Hi, I'm not sure if the AST would allow us to do this, but it would be great if this formatting of comment placement was preserved by ormolu:

if something
  -- then comment
  then do
    stuff
    stuff
  -- else comment
  else do
    stuff
    stuff

When formatted, this looks like

if something
  then -- then comment
  do
    stuff
    stuff
  else -- else comment
  do
    stuff
    stuff

One workaround is to place comments at the top of each alternative, which is okay, but seems a little less natural.

if something
  then do
    -- then comment
    stuff
    stuff
  else do
    -- else comment
    stuff
    stuff

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    commentsIssues related to comment placementstyleNitpicking and things related to purely visual aspect for formatting.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions