Opened 20 months ago

Last modified 19 months ago

#14876 new bug

Reading source files in text mode so that we get CRLF conversion under Windows?

Reported by: SimonHengel Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.2.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


According to the string passed to a quasi quoter contains CRLF line endings. I have observed the same things for Haddock comments (both in haddock and doctest when extracted through the GHC API).

I haven't looked at any GHC code, but wouldn't the right thing be to read source files in text mode so that we get newline conversion? If we don't want / can't do that for some reason, then wouldn't we still want to handle this somewhere deep down the stack so that not every client has to deal with it separately?

Change History (3)

comment:1 Changed 20 months ago by bgamari

GHC uses its StringBuffer abstraction, which is essentially just a bytestring, to read source files. hGetStringBuffer opens the file in binary mode, leaving UTF-8 decoding to nextChar and friends. In principle we could probably do newline conversion there.

That being said, I'm a bit weary of changing this in fear of breaking someone relying on the current behavior.

comment:2 Changed 19 months ago by SimonHengel

Should we consider to fix this for QuasiQuote only at first? I think passing CRLF to quasi quoters hardly makes sense and can be the source of windows specific bugs. But of course it's still a breaking change.

comment:3 Changed 19 months ago by SimonHengel

I haven't tried, but just from looking at the code for quoteFile I think that the current behavior is also inconsistent. quoteFile uses readFile and hence when we use a QuasiQuoter with quoteFile we will get newline conversions, while when we use the QuasiQuoter without quoteFile we do not get newline conversions.

Note: See TracTickets for help on using tickets.