String != [Char]

Malcolm Wallace malcolm.wallace at me.com
Mon Mar 26 17:34:45 CEST 2012


On 26 Mar 2012, at 16:20, Johan Tibell wrote:

> On Mon, Mar 26, 2012 at 7:48 AM, Malcolm Wallace <malcolm.wallace at me.com> wrote:
>>> In the region of this side of the Atlantic Ocean where I teach, the
>>> student population is very diverse
>> 
>> Prelude> putStrLn (take 5 "Fröhßen")
>> Fröhß
> 
> ghci> putStrLn "Fro\x0308hßen"
> Fröhßen
> ghci> putStrLn (take 5 "Fro\x0308hßen")
> Fröh
> 
> Your example works because your input happens to be in a normal form.

Yes indeed.  And I think it would be perfectly reasonable for the String (= [Char]) API to have a function "normalise :: String -> String" which would let the user deal with this issue as they see fit.  After all, if you are aware of the difference between combining characters and normalised characters, then you will want to make your own decision about what semantics you want from operations like "take".

Regards,
    Malcolm


More information about the Haskell-prime mailing list