So ... I used the unpacked vectors (from the vector package), preferably without much attention. vector-th-unbox makes instantiating for them a breeze, so why not.
Now I came across an instance where I was not able to automatically get these instances, a data type with parameters like phantom (like in Vector (s :: Nat) a , where s encodes the length).
This made me think about the differences between the Storable and Unboxed . Things I found out on my own:
Unboxed will store, for example, tuples as separate vectors leading to a better cache location without losing bandwidth when only one of these values ββis required.Storable will still be compiled into a simple (and probably efficient) readArray# that returns unboxed values ββ(as seen from reading the kernel).Storable allows you to use a direct pointer that allows you to interact with external code. Unboxed no.- [edit]
Storable instances are actually easier to write manually than Unbox (that is, vector and MVector )).
This in itself does not make me understand why Unboxed even exists, it seems to be of little use to it. I guess I missed something there?
source share