travitch / persistent-vector

Persistent vectors for Haskell based on array mapped tries
BSD 3-Clause "New" or "Revised" License
27 stars 4 forks source link

Unsliced vectors #17

Closed treeowl closed 3 years ago

treeowl commented 3 years ago

The slicing machinery was quite broken. Strip it out for now, with the hope of adding it back later in a more modular fashion (supporting both sliced and unsliced vectors). Lots of other changes popped up as I went.

Remove slicing machinery. Make the lazy folds actually lazy. Export versions of unsafeIndex that perform lookups eagerly. Make index perform its lookup eagerly. Don't reverse the tail to index into it; Make traverse use liftA2, which is faster than <$> with <*> for some instances. Make partition build its results eagerly, rather than producing enormous thunk chains. Improve Haddock formatting, using the relatively new MathJax support. Stop using a highly-unsafe local copy of runST. This mostly hasn't been needed since the introduction of runRW#, and the GHC folks continue to make improvements in that regard. Fix an assertion in Array.new, which previously banned creation of empty arrays. Make array folds index eagerly. Add a function to build arrays in reverse, so we don't have to reverse lists and then convert them to arrays in pushTail and newPath. *Simplify Arbitrary instances (this will be cleaned up in the no-empty branch).

treeowl commented 3 years ago

@travitch, I'm sorry to pile so much into one commit, but I'd really rather not go through the trouble to break this up. If you're okay with merging it as is, I'll move on to the no-empty stuff and then backport the improvements you made in #13.

travitch commented 3 years ago

Thanks! I'm very happy with this as an intermediate step. I can tackle adding those other functions back with inefficient implementations (and put those test cases back) to maintain API compatibility (not that I think I have a ton of users).

treeowl commented 3 years ago

Thanks! I urge you to wait with that till the no-empty branch lands. I don't want the rebase to be any harder.... I'll work on it today, I expect.