-
Notifications
You must be signed in to change notification settings - Fork 98
Support for CRLF line breaks #3
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
Conversation
How are you getting your strings into your parser? For some reason I was under the impression that some of the file-IO APIs did some normalization of newlines. |
Text IO (openFile, Data.Text) indeed performs newline conversion. |
I read files as |
It's a pity that newline has a return-value. Otherwise we could re-define newline as |
Alright, after thinking for a bit it seems like we could either:
Option (1) might break people so I'm leaning towards (2) (even though I have no data). |
I think very few people use the value returned by |
Actually, some people may be using parseSomeText :: Parser String
parseSomeText = many $ alphaNum <|> char ' ' <|> newline So I take back that the very few people use the value returned by |
I have renamed |
This is a provisional measure until `notFollowedBy` gets fixed. See #3 for more details
I - as many others - write parsers that run on different systems. Windows uses CRLF line breaks while Unix uses just LF. Currently, the
newline
parser only succeeds for LF line breaks. This leads to parsers that fail on one system but not the other, which is annoying.In my software, I frequently add the parsers I have attached in this pull request. I thought that they may be useful for other users of parsec. Basically, I am just adding CRLF line break support and a
anyNewline
parser, which succeeds for both LF and CRLF line breaks.If there is any concern about the names, they can be modified.