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

Bas van Dijk v.dijk.bas at gmail.com
Mon Nov 12 08:52:52 CET 2012

On 10 November 2012 17:57, Johan Tibell <johan.tibell at 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).


[1] http://hackage.haskell.org/packages/archive/bytestring/
[2] http://hackage.haskell.org/packages/archive/text/

More information about the Haskell-Cafe mailing list