[Haskell-cafe] vector to uvector and back again

Dan Doel dan.doel at gmail.com
Fri Feb 12 07:28:17 EST 2010

On Thursday 11 February 2010 8:54:15 pm Dan Doel wrote:
> On Thursday 11 February 2010 12:43:10 pm stefan kersten wrote:
> > On 10.02.10 19:03, Bryan O'Sullivan wrote:
> > > I'm thinking of switching the statistics library over to using vector.
> > 
> > that would be even better of course! an O(0) solution, at least for me ;)
> > let me know if i can be of any help (e.g. in testing). i suppose
> > uvector-algorithms would also need to be ported to vector, then.
> I could do this.

To this end, I've done a preliminary port of the library, such that all the 
modules compile. I've just used safe operations so far, so it's probably a 
significant decrease in performance over the 0.2 uvector-algorithms (unless 
perhaps you turn off the bounds checking flag), but it's a start. It can be 
gotten with:

  darcs get http://code.haskell.org/~dolio/vector-algorithms

I only encountered a couple snags during the porting so far:

  * swap isn't exported from D.V.Generic.Mutable, so I'm using my own.
  * I use a copy with an offset into the from and to arrays, and with a
    length (this is necessary for merge sort). However, I only saw a whole
    array copy (and only with identical sizes) in vector (so I wrote my own
  * Some kind of thawing of immutable vectors into mutable vectors, or other
    way to copy the former into the latter would be useful. Right now I'm
    using unstream . stream, but I'm not sure that's the best way to do it.

Other than that, things went pretty smoothly.

I haven't ported the test suite or benchmarks yet, so I don't recommend that 
anyone actually uses this for anything important yet.

-- Dan

More information about the Haskell-Cafe mailing list