Haskell Platform Proposal: add the 'text' library

Roman Leshchinskiy rl at cse.unsw.edu.au
Wed Oct 20 02:52:02 EDT 2010


On 20/10/2010, at 00:35, Duncan Coutts wrote:

> 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. 

True. But I didn't say it's a list of characters. It's a list of Chars, i.e., of Unicode code points.

> 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.

But text *does* have a list API. It doesn't get any "listier" than uncons, foldr and unfoldr. From my point of view, if these functions make sense for the data type then it's a list. If it's not a list then these functions don't make sense and shouldn't be provided.

Roman




More information about the Libraries mailing list