-
Notifications
You must be signed in to change notification settings - Fork 31
toUnfoldable leaks structure #135
Comments
There are some benchmarks here showing |
I've done some benchmarking: Sadly,
My inclination is to say that this means that |
Sorry, forgot to link to my benchmark branch: https://github.com/matthewleon/purescript-maps/tree/toUnfoldable-bench |
Yes, I think this makes sense. It's a breaking change, but I'd like to have |
I have to say that I really like the idea that a constraint could be used for something like this, too, in the same way that |
Right; it's difficult for me to imagine what that would look like, though. One way to expose this safely would be to define something like |
As a thought experiment, I'm wondering if this would necessarily be true with the right compiler optimizations... I would naïvely think that the compiler might to be able to optimize a |
addresses purescript-deprecated#135 toAscUnfoldable becomes a deprecated equivalent to toUnfoldable. We introduce `unsafeToUnfoldable` for the unsorted traversal.
toUnfoldable
currently leaks structure by doing a breadth-first traversal of theMap
.Potential solutions, subsequent to benchmarking:
If it turns out that
toUnfoldable
really isn't faster thantoAscUnfoldable
, thentoUnfoldable = toAscUnfoldable
should be a simple fix. It would break anything that was depending on the order oftoUnfoldable
, which is not what people should be doing. Maybe you also deprecatetoAscUnfoldable
.Put some sort of constraint on
toUnfoldable
to ensure that it unfolds to a structure where ordering is not important?Place a strongly worded, ugly warning comment on
toUnfoldable
.Other ideas?
The text was updated successfully, but these errors were encountered: