Closed treeowl closed 3 years ago
@travitch, I think this is ready for review.
Thanks, this is great! I appreciate you looking through the core to see what is really going on. I know that I had no idea how to do that when I first wrote this code.
I'm trying to remember why there was even an Empty
constructor. It seems obviously unnecessary now.
Remove the empty constructor, allowing GHC to unbox vectors.
Make strict folds a bit stricter and force them to inline, which lets GHC optimize
filter
,partition
, andreverse
to avoid allocating a fresh root node on everysnoc
. The folds now match list folds rather than the defaultFoldable
definitions. The inlining isn't free, but it seems pretty important. Also useList.reverse
just a tad infoldl'
andfoldr
to avoid likely-unproductive muck in the Core.Add
Foldable
method definitions.Use "unsafe" shifts.
Break up
snoc
so the common case can inline.Make
index
catch negative indices as well as ones that are too large.Define
//
in terms ofupdate
, rather than the other way around.Define
reverse
usingfoldr'
rather than working via a list.Unpack the vectors in the intermediate result of
partition
.Test unsafe indexing much more aggressively by testing all indices into the generated vector instead of just one.
Let the
Arbitrary
instances produce small vectors more easily; we can then set up CI to run the test suite with multiple size settings to catch any issues that might arise with small or large vectors.