String != [Char]

Ian Lynagh igloo at earth.li
Mon Mar 26 19:12:38 CEST 2012


On Mon, Mar 26, 2012 at 08:20:45AM -0700, 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.

I am very unicode-ignorant, so apologies if I have misunderstood
something, but doesn't Text do the same thing?

Prelude T> import Data.Text.IO as T
Prelude T T> T.putStrLn (T.take 5 (T.pack "Fro\x0308hßen"))
Fröh

Maybe your point is that neither "take" function should be used with
unicode strings, but I don't see how advocating the Text type is going
to help with that.


Thanks
Ian




More information about the Haskell-prime mailing list