byteverse / contiguous

Typeclass for array types
Other
18 stars 8 forks source link

Use functions from newer primitive and primitive-unlifted #63

Closed andrewthad closed 4 months ago

andrewthad commented 5 months ago

The implementation UnliftedArray in primitive-unlifted-2.1 penalizes the creation of an uninitialized unlifted array. When shrinking and resizing unlifted arrays, there are primitives that we can use to avoid this.

Also, primitive itself now has shims for common operations on PrimArray, so this commit also cleans up the Shim module.

andrewthad commented 5 months ago

I've made the changed you suggested. I've also gone through and remove several of the default implementations for things. As I was looking at the code, I realized that the default implementations of all the functions related to shrinking and in-place freezing just made it hard to reason about what was going on, and those are operations where I really want to know what's going on.

Let me know if there are any other concerns.

DaveBarton commented 4 months ago

Ping? There are just a very few corrections left. Maybe it's better to make these now while your memory is still fresh. Also I'd like to use the new library. :) Thanks!

andrewthad commented 4 months ago

Sorry, I had totally missed the notification when you left a review. I've merged all of your suggestions into the branch. Anything else, or should I go ahead and squash this down?

DaveBarton commented 4 months ago

Looks great! I think the only thing left is the comment in Class.hs, adding "It may be shrunk in place.":

I'd change line 142 to: -- | Resize a mutable array without growing it. It may be shrunk in place.