[Haskell-cafe] Unboxed arrays
lemming at henning-thielemann.de
Wed Mar 26 09:22:20 EDT 2008
On Wed, 26 Mar 2008, Roman Cheplyaka wrote:
> * Andrew Coppin <andrewcoppin at btinternet.com> [2008-03-26 12:37:53+0000]
>> Somebody asked me, so now I'm asking you...
>> In Haskell, you can make "unboxed" arrays of certain value types. These
>> are typically more efficient in space, and probably time too, and also
>> make the array strict in its values. However, you can only do this magic
>> trick for certain types - not for *all* types.
>> Why is that? Is it because nobody has done anything about it yet? Is it
>> because it's thought to be "not necessary" in some way? Is there some
>> theoretical problem? Has somebody got a better idea?
>> I did think it was along the lines of "oh, well, if you want to unbox a
>> type of your own, you just need to write your own instance". The thing
>> that makes me suspicious of this logic is the absense of an instance for
>> tuples. Surely this would be trivial to write, and yet it's not present.
>> If we had instances for a couple of sizes of tuples, it would surely be
>> quite easy to write your own custom instances that just sit on top of
>> this and tuple/untuple your custom values...
>> Any insights here?
> Could Data Parallel Haskell be useful for you?
> It was designed for parallel computation, but it includes unboxed
> arrays, nice list-like syntax and array comprehensions.
> 1. http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell
A light-weight unboxed array variant is:
I thought it might be more efficient sometimes to split, say Word8 and
Double data into two arrays, instead of padding data in order to align a
(Word8,Double) record, but this wouldn't fit into the array data
More information about the Haskell-Cafe