Skip to content

Conversation

@T-Gro
Copy link
Member

@T-Gro T-Gro commented Jan 23, 2026

Summary

Adds comprehensive complexity documentation to FSharp.Core collection modules using XML doc `` tags with Big-O notation.

Coverage

 ## Format

 \`\`\`fsharp
 /// <remarks>This is an O(n) operation, where n is the length of the array.</remarks>
 \`\`\`

 ## Validation

 - ✅ Builds with 0 XML warnings (--warnon:3390, --warnon:3520)
 - ✅ Complexity documentation propagates to generated FSharp.Core.xml

T-Gro added 14 commits January 22, 2026 17:38
- Added complexity documentation to all 47 Set functions/members
- Set type members: new O(n log n), Add/Remove/Contains O(log n), Count/IsEmpty O(1),
  Min/MaximumElement O(log n), set operations O(m log n), subset/superset O(n log m)
- Set module functions: empty/singleton/isEmpty O(1), add/remove/contains O(log n),
  fold/iter/exists/forall O(n), filter/map/partition O(n log n),
  union/intersect/difference O(m log n), ofList/ofArray/ofSeq O(n log n),
  toList/toArray O(n), toSeq O(1)
- Format: '<remarks>This is an O(...) operation, where n is...</remarks>'
- Build succeeds with 0 errors
- XML validation test passes
Added <remarks> with O(n) complexity documentation to all public Map
type members and module functions in map.fsi:

Type members (12): Add, Change, IsEmpty, new, ContainsKey, Count, Item,
Remove, TryFind, TryGetValue, Keys, Values

Module functions (31): empty, isEmpty, add, change, find, tryFind,
remove, containsKey, iter, tryPick, pick, exists, filter, partition,
forall, map, fold, foldBack, toSeq, toList, toArray, findKey,
tryFindKey, ofList, ofSeq, ofArray, count, keys, values, minKeyValue,
maxKeyValue

All remarks use consistent prose style following the pattern:
'Maps are represented as binary trees so this is an O(log n) operation'

Build: dotnet build src/FSharp.Core/FSharp.Core.fsproj -c Release - 0 errors
Tests: XmlDocumentationValidation - 1 passed
- Add O(n) complexity remarks for the @ (append) operator

Sprint 1 DoD:
- Build: ✅ 0 errors
- XML tests: ✅ Passed
- Map.fsi: ✅ 44 remarks
- @ operator: ✅ Documented
- No duplicates: ✅ Verified
- Add <remarks> with O() complexity info to all public List module functions
- Append complexity to existing remarks where applicable
- Follow prose format: 'This is an O(n) operation...'
- Lists are represented as linked lists - O(1) for head/tail, O(n) for indexing
Array module: 132 complexity remarks added
- O(1) for length, get, set, head, last, isEmpty, item, toSeq, singleton
- O(n) for most iteration/mapping operations
- O(n log n) for sorting operations
- O(n*m) for allPairs, transpose
- O(min(n,m)) for compareWith

Seq module: 92 complexity remarks added
- Lazy construction O(1) with O(n) enumeration for most operations
- O(n) for immediate operations like fold, iter, length
- O(n log n) for sorting
- O(k) space for distinct operations where k is unique elements
Added O(n) complexity documentation to 12 random* functions:
- randomShuffle, randomShuffleWith, randomShuffleBy: O(n)
- randomChoice, randomChoiceWith, randomChoiceBy: O(n)
- randomChoices, randomChoicesWith, randomChoicesBy: O(n * count)
- randomSample, randomSampleWith, randomSampleBy: O(n)

All 117 List module functions now have complexity remarks.
Build and XML validation tests pass.
- Fixed 43 duplicate <remarks> tags by merging complexity into existing remarks
- Added missing complexity remarks to 33 functions including all random* functions
- Fixed misplaced remark for Array.empty (between attributes)
- All 164 val declarations now have O(...) complexity in <remarks>
- Build: 0 warnings, 0 errors
- XmlDocumentationValidation test: 1 passed, 0 failed
Added O(n) complexity documentation to 12 random* functions in seq.fsi:
- randomShuffle, randomShuffleWith, randomShuffleBy
- randomChoice, randomChoiceWith, randomChoiceBy
- randomChoices, randomChoicesWith, randomChoicesBy
- randomSample, randomSampleWith, randomSampleBy

All functions have O(n) complexity because they first materialize
the sequence to an array before performing random operations.

Build: 0 errors
XmlDocumentationValidation: 1 passed, 0 failed
Merged 41 duplicate <remarks> tags where complexity remarks were added
separately from existing behavioral remarks. Each function now has at
most one <remarks> section containing both behavioral documentation and
complexity information.

- Build: 0 errors
- XmlDocumentationValidation test: 1 passed
- 107 remarks covering 118 val declarations
- No duplicate remarks tags per function
- Format correctly distinguishes lazy construction vs enumeration cost
Complete coverage: 118/118 functions now have complexity remarks

Added remarks for:
- indexed: Sequence construction is O(1), Enumeration is O(n)
- length: O(n) eager operation
- ofList: O(1) view operation
- replicate: O(1) construction, O(count) enumeration
- scanBack: O(n) eager, consumes whole sequence
- toArray: O(n) eager materialization
- removeAt: O(n) where n is the index
- updateAt: O(n) where n is the index
- insertManyAt: O(n) where n is the index
- average: O(n) eager operation
- contains: O(n) eager operation

Build: 0 errors, 0 warnings
XmlDocumentationValidation test: PASSED
- Remove duplicate complexity remarks from average function
- Merge duplicate remarks content into single tag for scanBack function
- Verified: Build passes with 0 errors, XmlDocumentationValidation test passes
- delay: O(1) construction, enumeration cost depends on generated sequence
- empty: O(1) operation
- nth: O(n) where n is the index
- sum: O(n) where n is the length of the sequence

This completes 100% coverage: 118/118 Seq functions now have complexity remarks.
- Added O(1) complexity remark to static member Cons (:: operator)

Complexity documentation summary:
- set.fsi: 47 remarks
- map.fsi: 43 remarks
- list.fsi: 117 remarks
- array.fsi: 164 remarks
- seq.fsi: 118 remarks
- prim-types.fsi: 3 remarks (Item, Cons, @)
Total: 492 complexity remarks across 6 files
@github-actions
Copy link
Contributor

github-actions bot commented Jan 23, 2026

❗ Release notes required


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/FSharp.Core docs/release-notes/.FSharp.Core/10.0.200.md

@T-Gro T-Gro marked this pull request as ready for review January 23, 2026 08:52
@T-Gro T-Gro requested a review from a team as a code owner January 23, 2026 08:52
@T-Gro T-Gro requested a review from abonie January 23, 2026 08:52
@T-Gro
Copy link
Member Author

T-Gro commented Jan 23, 2026

/run fantomas

@github-actions
Copy link
Contributor

🔧 CLI Command Report

  • Command: /run fantomas
  • Outcome: success

✅ Patch applied:
- Files changed: 1
- Lines changed: 62

@T-Gro T-Gro enabled auto-merge (squash) January 23, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

3 participants