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

> * Johan Tibell <johan.tib...@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
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to