[Haskell-cafe] Unboxed arrays

Andrew Coppin andrewcoppin at btinternet.com
Wed Mar 26 08:37:53 EDT 2008


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?



More information about the Haskell-Cafe mailing list