Haskell Platform Proposal: add the 'text' library

Duncan Coutts duncan.coutts at googlemail.com
Tue Oct 19 19:35:33 EDT 2010


On 19 October 2010 22:08, Roman Leshchinskiy <rl at cse.unsw.edu.au> wrote:
> On 19/10/2010, at 15:22, John Lato wrote:
>
>> I think there's a significant difference between vector and text, namely a Vector is conceptually the same as a list/1D array, while a Text is not.  I think this difference is enough to warrant a break from the list API.
>
> Are you sure? From its interface Text looks exactly like a list of Chars to me.

Right, that's a very common misunderstanding of Unicode. A Unicode
code point (type Char) does not correspond 1:1 with the human notion
of a character. It would be nice if it did, but unfortunately it is
not something we can ignore. Because of this it is better not to think
of operations on individual Chars but on short sequences of Chars. In
any case, when processing text (even ASCII where Chars do match
characters) many of the most common operations that you want are
substring not element based.

So this is why a list/vector API is not necessarily appropriate for text.

Duncan


More information about the Libraries mailing list