purescript-deprecated/purescript-maps

`toArray` method?

Closed this issue · 2 comments

Is it acceptable/possible to have a direct forall k v. Map k v -> Array (Tuple k v) method, as to not go through an intermediary List?

garyb commented

I'm not sure what the implementation for that would look like, since building it with a List and then converting to an Array is probably more efficient than doing the same thing directly with an Array (since it'd be O(n) for each addition to the Array but is O(1) for the List).

Maybe there's a way using an STArray or something, but I guess you'd still end up with something very similar as doing the List -> Array conversion, as you'd still have to fold over an implicit list of tuples, if not an actual List.

Fixed by the addition of toUnfoldable in 103122a.