[Repo Assist] fix: make Frequency.isSubset truly generic (remove hardcoded float key type)#378
Draft
github-actions[bot] wants to merge 2 commits intodeveloperfrom
Conversation
…y type) The inner helper function issubset was typed as list<float*int> and Map<float,int>, which forced F# type inference to constrain the outer isSubset to Map<float,int> despite its signature appearing generic. This meant isSubset could not be used with string, int, or any other key type produced by Frequency.createGeneric. Fix: replace explicit float type annotations in the helper with the generic type variable 'a, making isSubset work for all comparable key types. Add 6 tests covering float, string, int, and empty histogram cases. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## developer #378 +/- ##
=============================================
+ Coverage 47.61% 47.99% +0.37%
=============================================
Files 152 135 -17
Lines 16765 12930 -3835
Branches 2253 1709 -544
=============================================
- Hits 7983 6206 -1777
+ Misses 8097 6205 -1892
+ Partials 685 519 -166 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated pull request from Repo Assist, an AI assistant.
Summary
Fixes a silent type-constraint bug in
Frequency.isSubset.Root cause: The inner recursive helper
issubsethad explicit type annotationslist<float*int>andMap<float,int>. F# type inference propagated these constraints to the outer function, makingisSubsetaccept onlyMap<float,int>— despite the outer signature appearing generic (Map<_,int>). Users callingisSubseton a string or int histogram (created viaFrequency.createGeneric) would get a confusing type error.Fix: Replace the hardcoded
floattype annotations in the inner helper with the generic type variable'a, matching the intended semantics.Before:
After:
✅ All 1205 tests passed (1199 pre-existing + 6 new).