Home > Software engineering >  Haskell Massiv Array Size Limit
Haskell Massiv Array Size Limit

Time:01-10

If Massiv, as well as other array libraries use Int for indexing, then how does one construct and index arrays larger than 2^29 elements? Int can only be as large as 2^29. I noticed in the source code that Linear indexing is used on array operations aswell so I would assume that just writing a vector as a two dimensional array would still have the same issue.

Is there a solution to this within Massiv or is there another array library suitable for arrays with more than 2^29 elements?

Edit: @Thomas just mentioned that the maxBound of Int is machine dependent. How ever I would still like to know how to index arrays with a number of elements greater than the maxBound of Int.

CodePudding user response:

There is no way to create a list that contains more than maxBound :: Int elements in memory, because the size of an Int is generally expected to be sufficient to cover the full addressable memory space. A hypothetical list or array of length greater than maxBound :: Int on your system therefore would not fit in addressable memory and could not be stored, thus there is no need for a mechanism by which one could index into such a structure.

  • Related