-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
On Windows, results depend on file lineends used by Git #14
Comments
Note the issue is not triggered on AppVeyor, but it is triggered when checking files out on Windows using recommended Git settings (Windows newlines). Workaround for nikita-volkov/neat-interpolation#14, no more necessary if that bug is fixed.
I don't quite understand the concern here. Am I correct that the preprocessor retains the same line -separators as were used in the source-code sent to the compiler? |
Note the issue is not triggered on AppVeyor, but it is triggered when checking files out on Windows using recommended Git settings (Windows newlines). Workaround for nikita-volkov/neat-interpolation#14, no more necessary if that bug is fixed. This defines a variant of shouldBe; while at it, also integrate needed string type conversions.
Yes, you're correct. |
A better explanation. Do you agree that I should be able to replace [text|
a
b
|] and get the same result, irrespective of the used newlines in the source file? If so, your quasiquoter should modify newlines to be |
No problem. I completely disagree however. I think you're projecting on this library the requirements, which one would expect from the editor (i.e., the automatic line-separator normalisation). All the imaginable code-editors out there have the related settings. The library does only what it claims to do. If the user's code contains the |
My proposal would not pick Unix line endings for users; Windows line endings are converted to The truth is, this is probably a GHC bug. Binary files are a separate matter, but that's not your usecase.
Nope. I can't setup the editors of people checking out my sources, but by default (I guess) they'll preserve existing newlines. But again, Git won't. Prior artOther interpolation libraries work as I describe. Without even necessarily documenting it. interpolatedstring-qq in Haskell: Perl6 once violated the convention I describe, intentionally. Their entire testsuite became sensitive to users Git settings, and they changed their mind in 5 days after a ticket was filed. |
Here's a specific issue reaching the same conclusion: |
Hmm. I'm honestly conflicted on this. On the one hand, you make arguments which I acknowledge and you're obviously informed on the issue's spread, on the other, this is a very ambiguous case. I think the most "politically correct" way to approach this would be to introduce another quasi-quoter, which would provide the behaviour you expect. I however don't have time to approach this myself, I'm open to accept such a pull-request though. |
Thanks, I'll take a look at making a PR! |
For nikita-volkov#14. Missing: - full testing. - more complete docs. - using textNL in examples?
Values written using neat-interpolation use the newlines of the source file. On Windows that means they'll likely contain
\r\n
instead of\n
. That's unfortunate and unlikely to be intended, so I'd guess neat-interpolation should canonicalize newlines to\n
.Rationale 1: this package is used for string constants, so they better be constant.
Rationale 2: on Windows the actual newlines in a Git-managed project depend on how exactly Git was setup. The setup recommended by Git for Windows converts 2.9.2 them to Windows newlines.
Rationale 3: If I didn't use raw strings, I'd be writing
\n
in those strings. That's because the conversion to\r\n
is done at the lowest possible level (when writing to files opened in text mode).Use case:
A colleague used
neat-interpolation
(which is cool) in a test case I'm porting to Windows. However, I got the following:The expected value is written with a
neat-interpolation
quasiquote, and it has a\r\n
instead of\n
.EDITED: To confirm my analysis above, I resaved the specific file using Unix line ends, and the tests passed.
I didn't find any explicit mention of newlines in the package, but I could confirm this happens because even on Windows (somewhat sensibly)
lines
only processes\n
, leaving\r
alone:The text was updated successfully, but these errors were encountered: