haskell / primitive

This package provides various primitive memory-related operations.
Other
114 stars 58 forks source link

Add getSizeofSmallMutableArray #372

Closed treeowl closed 1 year ago

treeowl commented 1 year ago

@chessai I added some documentation since your review. Would you mind giving it a once-over?

konsumlamm commented 1 year ago

So sizeofSmallMutableArray sometimes returns the wrong result? We should think about deprecating it then, just like the underlying primitive.

treeowl commented 1 year ago

@konsumlamm The situation is slightly more complicated than that, I think. Originally, there was no primop for shrinking in place; "resizing" always meant copying. So a pure function for the size was totally fine. Now that there is a shrinking primop, we need to have an IO action to be sure to get the most recent size, rather than one that might be CSEed from earlier. However, it's arguably okay to use it in a program that doesn't use shrinking. Most programs, indeed, don't use shrinking. So ... I dunno if deprecation is right or not. I don't want to make that decision in this PR; we can discuss it in an issue if you like.

chessai commented 1 year ago

Agree that it should be a separate issue. For now this LGTM. Thanks for expanding the docs @treeowl .

treeowl commented 1 year ago

I've opened #373 to discuss that.

treeowl commented 1 year ago

Thanks for the review, @chessai .