On Mon, 18 Jun 2012, Roman Leshchinskiy wrote:

There are type families, rank-n types, unboxed types and other goodies deep in the guts of vector so the Storable part is very much GHC-specific. To be honest, I don't think being portable is feasible for high-performance code at the moment, the language standard simply doesn't have enough tools for this. Which is a shame, really.

I am not mainly interested in the efficient implementation. I am completely ok with having the definition of (Vector a) in a separate package, such that it can be used by vector (GHC only) and storablevector (portable).

However, I have just looked into Vector.Storable and it looks like

  data Vector a = Vector Int (ForeignPtr a)

I thought it was

  data Vector a = Vector {len :: Int, allocated :: ForeignPtr a, start :: Ptr a}

ByteString looks like:

  data ByteString = PS {allocated :: ForeignPtr Word8, start, length :: Int}

Both forms allow efficient slicing.
How do you perform efficient 'take' and 'drop' ?


FWIW, Storable vectors are fundamentally broken, anyway, since a Storable instance can perform arbitrary I/O in its methods but a pure vector based on Storable will necessarily have to unsafePerformIO these operations.

That's unfortunately true.

Storable should *really* live in ST but it's too late for that now.

How would this prevent from broken pointer arithmetic?

_______________________________________________
Haskell-platform mailing list
Haskell-platform@projects.haskell.org
http://projects.haskell.org/cgi-bin/mailman/listinfo/haskell-platform

Reply via email to