[Haskell-cafe] Bytestring package: Int and Int64
Johan Tibell
johan.tibell at gmail.com
Tue May 24 10:42:34 CEST 2011
Hi Daniel,
On Tue, May 24, 2011 at 10:07 AM, Daniel Díaz <danieldiaz at asofilak.es> wrote:
> Hi, cafe,
>
> I just feel curiosity. In the bytestring package, Data.ByteString module,
> functions like length, index, and others with Int in its type signature,
> have Int64 in the analogous Data.ByteString.Lazy version. What is the
> reason?
A strict ByteString is one contiguous chunk of memory so it cannot be
longer than an Int (if we assume and Int is either 32 or 64 bits for a
second). However, a lazily generated stream can be much bigger than
main memory, so it makes sense to use a bigger type to refer to e.g.
it length. Now, you might say that lazy ByteString should use Integer
instead of Int64. However, Int64 performs much better so I think the
loss of generality is worth it.
Johan
More information about the Haskell-Cafe
mailing list