Non-determinism in newline in the Haskell report

Ian Lynagh igloo@earth.li
Sat, 2 Feb 2002 14:37:45 +0000


Hi all,

The report says

whitechar    -> newline | return | linefeed | vertab | formfeed
             |  space | tab | uniWhite
newline      -> a newline (system dependent)
return       -> a carriage return
linefeed     -> a line feed

so, if your system defines a newline to be a line feed, an
implementation is free to choose whether to lex a line feed as a
whitechar or a newline, which makes quite a difference when you consider
the layout rule!

newline can't be arbitrarily determined by the system - certainly "x"
or "let" would not be acceptable - and having it system dependent means
that Haskell scripts are not portable between different systems. I
haven't looked but I would be surprised if current implementations
behaved differently on different platforms - I assume they all look for
something matching (<CR><LF>?)|<LF> everywhere.

I propose replacing the above with the following. It does mean that
<CR><LF> creates 2 newlines, but I don't believe this should be a
problem.

whitechar    -> newline | vertab | formfeed |  space | tab | uniWhite
newline      -> return | linefeed
return       -> a carriage return
linefeed     -> a line feed


Thanks
Ian, who really should have noticed this months ago