[Haskell-cafe] Motion to unify all the string data types

Johan Tibell johan.tibell at gmail.com
Sat Nov 10 17:57:26 CET 2012


On Fri, Nov 9, 2012 at 10:22 PM, Roman Cheplyaka <roma at ro-che.info> wrote:

> * Johan Tibell <johan.tibell at gmail.com> [2012-11-09 19:00:04-0800]
> > As a community we should primary use strict ByteStrings and Texts. There
> > are uses for the lazy variants (i.e. they are sometimes more efficient),
> > but in general the strict versions should be preferred.
>
> I'm fairly surprised by this advice.
>
> I think that lazy BS/Text are a much safer default.
>
> If there's not much text it wouldn't matter anyway, but for large
> amounts using strict BS/Text would disable incremental
> producing/consuming (except when you're using some kind of an iteratee
> library).
>
> Can you explain your reasoning?
>

It better communicates intent. A e.g. lazy byte string can be used for two
separate things:

 * to model a stream of bytes, or
 * to avoid costs due to concatenating strings.

By using a strict byte string you make it clear that you're not trying to
do the former (at some potential cost due to the latter). When you want to
do the former it should be clear to the consumer that he/she better consume
the string in an incremental manner as to preserve laziness and avoid space
leaks (by forcing the whole string).

-- Johan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20121110/36df86fc/attachment.htm>


More information about the Haskell-Cafe mailing list