fsprojects / fsprojects/FSharpPlus

Groups should be NonEmptySeqs

Open
#480 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
F#
Stars
941
Forks
106
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing grouping functions, especially chunkBy, alongside F# core groupBy behavior. Determine which grouping APIs could return NonEmptySeq and assess the stated backward-compatibility and seq upcasting concerns. Done means the API scope and compatibility approach are agreed and implemented.

Written by the indexing model from the issue text.

Assessment

Tech stack
fsharp
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.