tweag / ormolu

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

Ormolu deletes comments from source code #524

Closed kolree closed 4 years ago

kolree commented 4 years ago

The original input:

instance Foo Int where

  -- Here goes a comment.
  --
  --   something
  -- * something

  foo :: Int
  foo = 0

gets reformatted into:

instance Foo Int where
  -- Here goes a comment.
  --
  --   something

  foo :: Int
  foo = 0

The part of the comment starting with -- * is lost.

mrkkrp commented 4 years ago

Please provide code snippets that show your original input and the result after formatting. I do not know how to make that site format the snippet (Ctrl-I does nothing for me) and the example probably can be minified.

symbiont-eric-torreborre commented 4 years ago

Here is another example:

function1 :: Int -> Text
function1 n =
  function2 n "***"
  where
    -- | this is function 2
    --   it calls show
    function2 n t = show n <> t

gets reformatted into

function1 :: Int -> Text
function1 n =
  function2 n "***"
  where
    function2 n t = show n <> t

The whole haddock-like section disappears

mrkkrp commented 4 years ago

That’s different, it’s #474.

symbiont-eric-torreborre commented 4 years ago

Thanks Mark.

mrkkrp commented 4 years ago

Apparently this is how GHC parser works. It picks up the lines that start with -- * and removes them.

mrkkrp commented 4 years ago

Essentially the same as #474.

symbiont-eric-torreborre commented 4 years ago

Let's close it as a duplicate then.