linesPS is not analagous to lines
David Roundy
droundy@abridgegame.org
Sun, 13 Apr 2003 13:33:44 -0400
I've just switched my code to use PackedStrings rather than Strings for
file contents, and ran into what appears to be a bug in the
Data.PackedString module in ghc 5.04.3.
unlines is the inverse of lines, since lines converts empty lines into
empty strings. linesPS, however, ignores empty lines. :( It seems like
it would be a good idea to either fix this (which might not be a good idea,
if existing code depends on its current behavior), or add a note in the
documentation that it isn't analagous to lines, so that other people won't
make the same mistake based on its similar name.
My example program that demonstrates this:
import Data.PackedString
main = do
temp <- return $ packString "hello\nworld\n\nI\njust\nskipped\n\n a line\n"
putStr $ "The unlines of linesPSed version:\n\n"
putStr $ unlines $ map unpackPS $ linesPS temp
putStr $ "The unlines of linesed version:\n\n"
putStr $ unlines $ lines $ unpackPS temp
--
David Roundy
http://www.abridgegame.org