tweag / ormolu

A formatter for Haskell source code
https://ormolu-live.tweag.io
Other
956 stars 83 forks source link

Comments in type families are unindented #913

Closed brandonchinn178 closed 2 years ago

brandonchinn178 commented 2 years ago

Describe the bug When comments are in type families, they become unindented

To Reproduce

type family LT a b where
  -- 0
  LT 0 _ = True

  -- 1
  LT 1 0 = False
  LT 1 _ = True

  -- 2
  LT 2 0 = False
  LT 2 1 = False
  LT 2 _ = True

reformats to

type family LT a b where
-- 0
  LT 0 _ = True
-- 1
  LT 1 0 = False
  LT 1 _ = True
-- 2
  LT 2 0 = False
  LT 2 1 = False
  LT 2 _ = True

Expected behavior

type family LT a b where
  -- 0
  LT 0 _ = True
  -- 1
  LT 1 0 = False
  LT 1 _ = True
  -- 2
  LT 2 0 = False
  LT 2 1 = False
  LT 2 _ = True

As a bonus, it would be great if the newlines could be preserved

Environment

Additional context Add any other context about the problem here.