[Haskell-cafe] fast Array operations: foldl, drop
Jules Bean
jules at jellybean.co.uk
Thu Nov 29 06:29:08 EST 2007
Henning Thielemann wrote:
> I thought operations like "foldl'" and "drop" must be very fast on arrays
> (especially UArray) with appropriate pointer tricks, I mean pointer
> incrementing instead of indexing for "foldl'" and a pointer into the array
> for "drop". Is it planned to add such functions? Ok, if "foldl f x .
> elems" and "listArray (i,sufficientlyBig) . drop n . elems" are fused to
> high speed code, then these functions do not need to materialize in the
> API.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
As far as I'm aware, our arrays don't support any kind of zero-copy
slicing, which is what your 'drop' trick amounts to.
Zero-copy slicing would seem like an obviously nice thing to have for
IArrays, though, I agree. For various different kinds of slices
including projections.
ByteString supports zero-copy substring, but it's based on ForeignPtr
not UArray.
On the fusing point I believe that the stream fusers believe they can
make things like foldl . elems fuse but I'm not sure.
Jules
More information about the Haskell-Cafe
mailing list