Skip to content

[Repo Assist] feat: add TaskSeq.tryMax and TaskSeq.tryMin#419

Merged
dsyme merged 2 commits intomainfrom
repo-assist/improve-trymax-trymin-20260508-f1717f1ca85019fb
May 8, 2026
Merged

[Repo Assist] feat: add TaskSeq.tryMax and TaskSeq.tryMin#419
dsyme merged 2 commits intomainfrom
repo-assist/improve-trymax-trymin-20260508-f1717f1ca85019fb

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 8, 2026

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Adds TaskSeq.tryMax and TaskSeq.tryMin — safe, option-returning variants of TaskSeq.max and TaskSeq.min that return None instead of raising ArgumentException when the input sequence is empty.

Motivation

TaskSeq.max and TaskSeq.min throw ArgumentException on empty sequences (matching Seq.max/Seq.min behaviour). A try-prefixed variant follows the established pattern in this library (tryHead, tryLast, tryExactlyOne, tryItem, tryFind, tryPick, ...) and mirrors F# 8's Seq.tryMax/Seq.tryMin.

Implementation

  • TaskSeqInternal.fs: adds tryMaxMin helper — same loop as maxMin but uses MoveNextAsync() directly for the first element, returning Some acc or None instead of raising
  • TaskSeq.fs: two one-liners delegating to Internal.tryMaxMin
  • TaskSeq.fsi: XML-documented signatures for tryMax and tryMin
  • TaskSeq.MaxMin.Tests.fs: 10 new tests in a TryMaxMin module covering null, empty variants, singleton, immutable variants (via TestImmTaskSeq), agreement with max/min, and side-effect re-iteration

Test Status

Build succeeded.    0 Warning(s)    0 Error(s)

Passed! - Failed: 0, Passed: 5430, Skipped: 2, Total: 5432

Formatting verified clean (dotnet fantomas . --check exit 0).

Closes nothing — this is a new API addition.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@fc4ab36dedc44e2a1cdc195cecce262f06c81230

Safe option-returning variants of TaskSeq.max/min that return None
for empty sequences instead of raising ArgumentException. Follows
established 'try' patterns (tryHead, tryLast, tryExactlyOne, etc.)
and mirrors F# 8's Seq.tryMax/Seq.tryMin.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review May 8, 2026 16:27
@dsyme dsyme merged commit 4865e28 into main May 8, 2026
5 checks passed
@dsyme dsyme deleted the repo-assist/improve-trymax-trymin-20260508-f1717f1ca85019fb branch May 8, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant