-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test that correct overloads are used #323
Comments
@wallymathieu I think this feature is independent of the F#+ version. Isn't it? |
Should be. It would be nice to have it verified for both the 1 and 2 versions. |
The key question here is, how do we implement this? I can think of:
Other ideas? |
One way to do it would be to inspect compiled usage in order to verify that the correct overload has been chosen by the compiler. |
Implemented in #557 |
Forked out from #288 (comment)
In that issue it seems to be a slight worry that generic operators like
filter
,map
,choose
etc. may not call the most optimal overloads. This worry is based on the fact that theSeq
can or could subsume calls usingarray
,List
,Set
, etc.One example of where this is particularly important is
length
, whereSeq.length
is O(N) butArray.length
is O(1), so if you calllength myArray
then you want to be absolutely sure that you are in practice callingArray.length
, notSeq.length
. This is just an important example though; AFAIK the built-inArray.choose
,Array.map
etc. have better performance thanSeq.choose
,Seq.map
etc. (e.g. less allocations and better cache locality) and thus the correct overload should always be used even though the actual time complexity may be the same.The goal is that users of FSharpPlus must be able to rely on the correct overload being called without thinking about subsumption etc. In concrete terms, when they pass a
List
,Set
,array
or anything else to a generic operator likefilter
,map
,choose
, etc., then the overload that is used should be the one that callsList.filter
,Set.map
,Array.choose
etc. and notSeq.filter
,Seq.map
, andSeq.choose
.There should ideally be automated tests for this, and it should be clearly documented that users can rely on this.
The text was updated successfully, but these errors were encountered: