big static random access arrays
|Reported by:||jsnx||Owned by:|
|Keywords:||static array||Cc:||SamB, core-libraries-committee@…|
|Type of failure:||None/Unknown||Test Case:|
|Related Tickets:||Differential Rev(s):|
These would be unlike StorableArrays because they would be available at compile time, and would be pure values. They would amount to arrays of bytes, of course, but it'd be nice if they could be (Storable a) => StaticArray a and we could walk down them or randomly access them to get the a values out of them. They should be capable of storing hundreds of thousands of Ints.
What are some functions that work on these arrays? We need just one:
indexInto :: (Storable a) => StaticArray a -> Word -> a
Then we can make a Monad to walk up and down the array. It will be some State hybrid. No IO. A bright person could implement static Tries, RoseTrees and other things using this Monad -- storing the offsets mixed in with the data in an unholy mess and skipping forward or backward, leveraging "the world’s most beautiful imperative language."
It's been suggested (SamB) that this should be implemented in Template Haskell.
Important features of this array relative to other arrays and lists in Haskell:
- Specificity of Index
- A machine Word since that contains the finest grained pointer. When indexing into a Storable a, the index is multiplied by sizeOf (undefined :: a).
- Static Nature
- Exists to facilitate large static constants. The array does not support any append or delete operations, there is no way to change any of its values and it can not be copied.
Change History (6)
comment:4 Changed 8 years ago by simonmar
- Operating System changed from Multiple to Unknown/Multiple
comment:5 Changed 22 months ago by thomie
- Cc core-libraries-committee@… added
- Component changed from Compiler to Core Libraries
- Owner set to ekmett
- Type of failure set to None/Unknown