FSharpPlus
FSharpPlus copied to clipboard
toSeq defaults
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
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.
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.