[Haskell-cafe] Why Maybe exists if there is Either?
Richard A. O'Keefe
ok at cs.otago.ac.nz
Wed Jan 22 01:56:36 UTC 2014
On 10/01/2014, at 8:36 PM, John Lato wrote:
> An abstract String would also be better than our current situation because Data.List functions on Strings are just plain wrong anyway. Simple example: what should be the reverse of "This is two lines\r\nbecause Windows!\r\n"? It gets even more fun with unicode.
Linear sequences of characters are a fundamentally broken data type
no matter how you represent them in the computer. John Lato gave
this link: http://msmvps.com/blogs/jon_skeet/archive/2009/11/02/omg-ponies-aka-humanity-epic-fail.aspx
where in the course of making a valid point, the author made the mistake
which should of course be
And when he wrote "Unicode has its own special line terminator character as well"
he should have said "Unicode adds THREE more special characters": the Latin-1
Next Line character (U+0085), Line Separator (U+2028), and Paragraph Separator
(U+2029). Just to add to the fun, \r, \n, \r\n, and \205 are line
*terminators* while the other two are *separators*.
Unicode is *insanely* complicated. It includes a set of *prefix*
operators (the "Ideographic Description Characters") for describing
*trees* of Chinese characters to be displayed in a single box, but
a set of *postfix* operators for other things like accents and for
saying "the FUEL PUMP U+26FD characte preceding should be in colour"
[VS15 = "text style", VS16 = "emoji style", see
http://www.unicode.org/L2/L2011/11438-emoji-var.pdf]. And just to
complete the trifecta, there's a distfix operator
<interlinear annotation anchor> base text <interlinear
annotation separator> annotation text <interlinear annotation terminator>.
Oh, I didn't mention the *infix* operator "combining grapheme cluster".
If there is _any_ sane way to reverse a Unicode string,
which I rather doubt,
it would be _horrible_ to implement it.
And frankly, the use of lists here would *not* contribute
materially to the difficulty.
(For the record, I tried to implement a string reversal operation
that made sense for Unicode, and very quickly became extremely
More information about the Haskell-Cafe