Skip to content
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

toSeq defaults #449

Open
gusty opened this issue Jun 4, 2021 · 2 comments
Open

toSeq defaults #449

gusty opened this issue Jun 4, 2021 · 2 comments
Labels
enhancement F#+ v2.0 fix A fix for something that it's not a bug but needs fixing

Comments

@gusty
Copy link
Member

gusty commented Jun 4, 2021

ToSeq Invokable has an overload for IEnumerable which has lower priority than the custom implementation (ToSeq explicitly defined on the type).

This cause some inconsistencies, in dictionary like types where toSeq doesn't give back the same as [type].toSeq.

However fixing this is technically a breaking change, we might have to wait for v2

@gusty
Copy link
Member Author

gusty commented Jun 4, 2021

It worth noting that toList and toArray don't have this problem as there the IEnumerable overload has the least priority.

I'm not sure, what was the reason toSeq was done like that, maybe was just a distraction or could be a design decision.

@gusty
Copy link
Member Author

gusty commented Jun 4, 2021

Still:

> Map.ofList [1, 'a'; 3, 'b']  |> Map.toList  ;;
val it : (int * char) list = [(1, 'a'); (3, 'b')]

> Map.ofList [1, 'a'; 3, 'b'] |> toList  ;;
val it : System.Collections.Generic.KeyValuePair<int,char> list =
  [[1, a] {Key = 1;
           Value = 'a';}; [3, b] {Key = 3;
                                  Value = 'b';}]

This is because Map is a built-in type and there is no specific overload to handle it, so it defaults to the IEnumerable one.

This should also be fixed as part of this issue.

@gusty gusty added enhancement F#+ v2.0 fix A fix for something that it's not a bug but needs fixing labels Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement F#+ v2.0 fix A fix for something that it's not a bug but needs fixing
Projects
None yet
Development

No branches or pull requests

1 participant