Add note about sorting to documentation (and possibly a transform function)
- Dominant language
- Haskell
- Stars
- 400
- Forks
- 145
- PR merge metrics
- No merged PRs in 30d
Description
Continuing from #157 - sorting algorithms are available in `vector-algorithm`, but it isn't easy to find that information out, depending on how you search. For example, the Stackage Hoogle query for [sort :: Ord a => Vector a -> Vector a](https://www.stackage.org/lts-12.22/hoogle?q=sort+%3A%3A+Ord+a+%3D%3E+Vector+a+-%3E+Vector+a) doesn't come up with the result (because that package doesn't provide a wrapper for immutable vectors).
It would be nice if a note about this could be added to the top-level module `Data.Vector`, which serves as the "information hub" right now. Something along the lines of:
> Note: Sorting algorithms for mutable vectors are available in the [vector-algorithms](https://hackage.haskell.org/package/vector-algorithms) package. If you want to sort an immutable vector, you can use the [`freeze`](https://hackage.haskell.org/package/vector-0.12.0.2/docs/Data-Vector-Generic.html#v:freeze) and [`thaw`](https://hackage.haskell.org/package/vector-0.12.0.2/docs/Data-Vector-Generic.html#v:thaw) functions to wrap calls to sorting functions of your choice.
Personally, I think it would be nice to have a helper function alongside
```
Data.Vector.Generic.transform
:: (PrimMonad m, Vector v a)
=> (Mutable v (PrimState m) a -> m (Mutable v (PrimState m) a))
-> v a
-> m (v a)
transform f = unsafeFreeze <=< f <=< thaw
```
as an counterpart to [Data.Vector.Generic.Mutable.transform](https://www.stackage.org/haddock/lts-12.9/vector-0.12.0.1/Data-Vector-Generic-Mutable.html#v:transform) (the signatures aren't exactly analogous though because of the extra `m` :slightly_frowning_face:), but of course, it isn't strictly necessary, just a nice to have thing.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.