
[ moving to libraries@haskell.org... ]
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.
Indeed, that looks like a bug. linePS is defined as (splitPS '\n'), and it appears that splitPS strips out empty substring matches. wordsPS uses this property, so that it works analogously to List.words (which doesn't return any empty words). However, the comment in the code says that joinPS (packString [x]) (splitPS x ls) = ls which isn't true if splitPS removes empty substrings. It therefore looks like splitPS is wrong to drop empty substrings, and wordsPS should explicitly filter them out. I'll make this change unless anyone complains. Also, I just noticed that joinPS is missing from Data.PackedString, for no apparent reason. Cheers, Simon