Conversation
It feels like these should have
Windowed sorting/grouping with incremental diff suitable for infinite collections would be kind of cool but should likely be part of integrating with a library like FSharp.Data.Adaptive where incremental changes between collections can be part of the computational structure? |
|
Thanks so much for the feedback @dsyme. I'll update these to return Yes, it probably makes more sense for them to have |
Yes that's a reasonable consideration - the However somehow it feels a little too much to lose both async and on-demand. It feels like the code is always going to be clearer if at least one of those information-losses is made explicit. This is partly because I belive AsyncSeq is in practice used on infinite lists of events (listening to data updates) more than Seq is (relative to overall use). |
|
Thanks for clarifying that. I've updated them to return |
|
@dsyme please take a look when you have a minute. Thanks. |
| yield buffer.ToArray() } | ||
|
|
||
| let toSortedSeq fn source = | ||
| toArrayAsync source |> Async.map (fun source' -> (fn source' :> seq<'T>)) |> Async.RunSynchronously |
There was a problem hiding this comment.
Hmmmm.... since they all use toArrayAsync maybe the return type should just be an honest array!
This PR implements
sort,sortBy,sortDescendingandsortByDescendingfunctions and addresses the issue/feature request #126I have assumed that
AsyncSeqis more about asynchronous nature of the type than the infinite nature of it. Therefore, I have implemented these usingSeq.sort,Seq.sortBy,Seq.sortDescendingandSeq.sortByDescendingi.e. I have not considered implementing some sort of time-windowed sorting feature. Like theirSeqcounterparts, these functions are not intended to be used in large or infinite sequences.In terms of unit testing, I have added just a test each for testing integer sequences. This feels like a good usecase for property-based testing using a framework like
FsCheckbut I haven't seen any property-based tests here so decided not to bother. Please let me know if you think introducing property-based tests would add value to this repo and I will bring inFsCheckand add some more tests for the above functions.Thank you 🙂