String != [Char]
Christian Siefkes
christian at siefkes.net
Mon Mar 26 18:42:03 CEST 2012
On 03/26/2012 05:50 PM, Johan Tibell wrote:
> Normalization isn't quite enough unfortunately, as it does solve e.g.
>
> upcase = map toUppper
>
> You need all-at-once functions on strings (which we could add.) I'm
> just pointing out that most (all?) list functions do the wrong thing
> when used on Strings.
Hm, do you have any other examples besides toUpper/toLower?
Also, that example is not really an argument against using list functions on
strings (which, by any reasonable definition, seem to be "sequences of
characters" -- whether that sequence is represented as a list, an array, or
something else, seems more like an implementation detail to me). Rather, it
indicates the fact that Char.toUpper may have to wrong type. If its type was
Char -> String instead of Char -> Char, it could handle things like toUppper
'ß' == "SS" correctly. Then stuff like
upcase = concatMap toUppper
would work fine.
As it is, the problem seems to be with Char, not with [Char].
Best regards
Christian
--
|------- Dr. Christian Siefkes ------- christian at siefkes.net -------
| Homepage: http://www.siefkes.net/ | Blog: http://www.keimform.de/
| Peer Production Everywhere: http://peerconomy.org/wiki/
|---------------------------------- OpenPGP Key ID: 0x346452D8 --
Failure is just success rounded down.
-- Ryan North
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://www.haskell.org/pipermail/haskell-prime/attachments/20120326/63361ce9/attachment.pgp>
More information about the Haskell-prime
mailing list