[Haskell-cafe] Re: String vs ByteString

Ketil Malde ketil at malde.org
Fri Aug 13 17:04:25 EDT 2010


Kevin Jardine <kevinjardine at gmail.com> writes:

> Almost every modern programming language has one or at most two
> standard representations for strings.

> That includes PHP, Python, Ruby, Perl and many others. The lack of a
> standard text representation in Haskell has created a crazy patchwork
> of incompatible libraries requiring explicit and often inefficient
> conversions to connect them together.

Haskell does have a standard representation for strings, namely [Char].
Unfortunately, this sacrifices efficiency for elegance, which gives rise
to the plethora of libraries.

> I end up with a program littered with ugly
> pack, unpack, toString, fromString and similar calls.

Some of this can be avoided using a language extension that let you
overload string constants.

There are always trade offs, and no one solution will fit all: UTF-8 is
space efficient while UTF-16 is time efficient (at least for certain
classes of problems and data).  It does seem that it should be possible
to unify the various libraries wrapping bytestrings (CompactString,
ByteString.UTF8 etc), however. 

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants


More information about the Haskell-Cafe mailing list