FSharpPlus icon indicating copy to clipboard operation
FSharpPlus copied to clipboard

Groups should be NonEmptySeqs

Open gusty opened this issue 3 years ago • 0 comments

When grouping sequences typically through a groupBy operation, all subsequences we get are never empty.

This means that using a NonEmptySeq should be more appropriate and it will provide additional compile time guarantees for further operations, typically aggregation operations.

The problem is that these grouping operations are defined in F# core and it's against this library design guidelines to redefine a function coming from F# core, for good reasons.

But we could redefine our grouping functions, for instance chunkBy will never yield an empty group. Here the problem is backwards compatibility and the additional burden incurred in having to eventually upcast to seq for certain operations. But for F# 6 it shouldn't be an issue since it does it automatically.

gusty avatar May 30 '22 08:05 gusty