[Haskell-cafe] GHC.Prim: Resizable Multidimensional array

Jake jake.waksbaum at gmail.com
Fri May 6 12:52:30 UTC 2016

I'm trying to create a resizable multidimensional array using the primitive
array stuff in GHC.Prim. I see that the only resizable array is the
ByteArray#, but the only array that supports multidimensionality is the
ArrayArray# as far as I can tell.

I have groups of 4 Double#s that I want to have a resizable array of, so
only really the "first dimension" needs to be resizable. I was thinking if
there was a way to get the pointer of a SmallArray# as an Addr# I could use
the ability of ByteArray#s to store Addr#s.

The other option I was considering was to simply have a mapping similar to
the ones provided by Data.Ix that maps pairs of numbers to a single index,
and in that way use a single ByteArray# to store everything. However,
because this will be a fairly large array it seems like it is a much better
idea to avoid allocating and reallocating that humongous chunk of memory
when I can keep it spread out in smaller chunks by storing pointers to
smaller arrays in the larger array. But maybe that isn't an important

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160506/7405ff8a/attachment.html>

More information about the Haskell-Cafe mailing list