Alternative 'lines' implementation that understands CR-LF and CR

LTS Haskell 22.25:0.1
Stackage Nightly 2024-06-16:0.1
Latest on Hackage:0.1

See all snapshots portable-lines appears in

BSD-3-Clause licensed by Joey Adams
Maintained by [email protected]
This version can be pinned in stack with:portable-lines-0.1@sha256:21c3b905888a4b43f957cd8e8cdf2af00942bb161aa19a6b20db18b661de0510,1552

Provides an alternative implementation of the Prelude.lines function that treats the following sequences as newline characters:

  • "\r\n" (Windows style)

  • "\r" (Macintosh style, before OS X)

  • "\n" (Unix style)

Haskell's IO system supports both platform-specific line ending conversion (by opening the file in "text mode"), and explicit setting of the newline mode for input and output (see System.IO.hSetNewlineMode). However:

  • If you don't know the line ending format in advance, you would have to open the file and detect the newline format manually.

  • ByteString currently honors neither of these; see http://stackoverflow.com/questions/6837628.