On 10 November 2012 17:57, Johan Tibell <johan.tib...@gmail.com> wrote:
> 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).

Good advice.

And when you want to do the latter you should use a Builder[1] (or [2]
if you're working with text).

Bas

[1] 
http://hackage.haskell.org/packages/archive/bytestring/0.10.2.0/doc/html/Data-ByteString-Builder.html
[2] 
http://hackage.haskell.org/packages/archive/text/0.11.2.3/doc/html/Data-Text-Lazy-Builder.html

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to