ghc-exactprint icon indicating copy to clipboard operation
ghc-exactprint copied to clipboard

exactPrinted comments seem to gain additional carriage returns on Windows

Open jrp2014 opened this issue 4 years ago • 0 comments

ghc-exactprint 0.6.3.1 (ghc-8.10.1) works well on Windows for most code, but it seems to insert extra carriage returns in comments.

For example,

--Another comment
--

newtype N a = Int a

data D a = A a  | B | C a

gets turned into:

--Another comment

--


newtype N a = Int a

data D a = A a  | B | C a

(there are \r\n, rather than \n at the end of each comment line. (Multi-line comments ({-) also have all their internal newlines replaced by cr+nl.)

There are two solutions:

  • get newline to push out \r\n, rather than \n, under Windows
  • always replace \r\nby\nwithin comments

Or you could offer both in different print styles, I suppose, because different people will have different git settings to handle this and golden test case output should be cross-platform.

jrp2014 avatar Jun 20 '20 17:06 jrp2014