[Haskell-cafe] Array, Vector, Bytestring

Ben Gamari bgamari.foss at gmail.com
Tue Jun 4 03:41:53 CEST 2013


Artyom Kazak <yom at artyom.me> writes:

> silvio <silvio.frischi at gmail.com> писал(а) в своём письме Mon, 03 Jun 2013  
> 22:16:08 +0300:
>
>> Hi everyone,
>>
>> Every time I want to use an array in Haskell, I find myself having to  
>> look up in the doc how they are used, which exactly are the modules I  
>> have to import ... and I am a bit tired of staring at type signatures  
>> for 10 minutes to figure out how these arrays work every time I use them  
>> (It's even worse when you have to write the signatures). I wonder how  
>> other people perceive this issue and what possible solutions could be.
>
> Recently I’ve started to perceive this issue as “hooray, we have lenses  
> now, a generic interface for all the different messy stuff we have”. But  
> yes, the inability to have One Common API for All Data Structures is  
> bothering me as well.
>
>> Why do we need so many different implementations of the same thing? In  
>> the ghc libraries alone we have a vector, array and bytestring package  
>> all of which do the same thing, as demonstrated for instance by the  
>> vector-bytestring package. To make matters worse, the haskell 2010  
>> standard has includes a watered down version of array.
>
> Indeed. What we need is `text` for strings (and stop using `bytestring`)  
> and reworked `vector` for arrays (with added code from `StorableVector` —  
> basically a lazy ByteString-like chunked array).
>
To be perfectly clear, ByteString and Text target much different
use-cases and are hardly interchangeable. While ByteString is, as the
name suggests, a string of bytes, Text is a string of characters in a
Unicode encoding. When you are talking about unstructured binary data,
you should most certainly be using ByteString.

Cheers,

- Ben



More information about the Haskell-Cafe mailing list