Mark P Jones <[EMAIL PROTECTED]> writes:
> 
> | Here's a Prelude inconsistency that's been irking me once 
> | in a while for a loong time - today it came up again, so here goes:
> | 
> |   unlines   ["a","b"]   ==> "a\nb\n"
> |   unwords ["a","b"]   ==> "a b"
> |
> | [... unwords adds space between items, not at the beginning or end;
> | unlines puts a newline after each item, including at the end ...]
> 
> I quite like the fact that the definition for unlines gives us laws
> like:
> 
>   unlines (xs ++ ys) = unlines xs ++ unlines ys
>   unlines . concat   = concat . map unlines
> 
> Of course, the fact that unwords doesn't add a terminating space
> means that we don't get quite such nice laws for unwords ...
> 

Hi Mark,

yes, those laws would be nice to have too. I guess this shows that
treating text as just a list, doesn't give you all the laws you
would like. In my case, prepending some lines to a paragraph should
ideally have resulted in a bigger paragraph (with no trailing newlines.)

Anyway, Pretty gives me the laws I need & is more suitable for
the job. No reason to tweak the defn of unlines.

--sigbjorn

Reply via email to