-
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
Possible undesired seq subsumption results in KeyValuePairs #322
Comments
@cmeeren Thanks for pointing out these 2 corner cases. Let's take dive on them:
of course, the error message is telling you that there was a subsumption and then type -check failed. A better error message would be, " Maybe there's a way to improve the error message by adding an overload that catches this situation.
But as you point out, by doing for instance
The ToSeq invokable has a simple overload that accepts subsumption on any The controversy comes from (as usual) the .NET framework which casts Map<int,int> as a seq<KeyValuePair<int,int>> so even without linking this library, if you do Now, if you think about Map has 2 type parameters while Going back to our Keep in mind it's really Short answer: there's no standard way to represent two type parameters into one, so we stick to what .NET already does. There's an open question here, forget all the above, the question could be: how a Map should fold Maybe it should fold only the values? If so, we can add overloads to fight back the automatic conversion (this would be a breaking change, so it would be for v2). There is a More thoughts welcome. |
I don't get it. What is
Thanks, I see I was mistaken.
AFAIK one should never use this |
Regarding the Empty instance for As you can see there, it would require it to implement As for But I said it's not an Applicative as it still lacks In order to match any application for any key, note that this is technically possible for finite sets, like
as the first term which resolved to
still this is far from practical for most types, we should have a kind of wildcard value for the key like for instance in the case of
Having said that, I reckon the distributive rule is rarely obeyed, that's one of the reasons I didn't include it in http://fsprojects.github.io/FSharpPlus/abstraction-alternative.html#Rules If we look carefully those rules, we can see that So, I would accept a PR that treats Maps (and why not dictionaries and possibly Sets) as alternatives as long as those rules are obeyed. |
Thanks for the explanation. It went a bit over my head. In any case, please don't go to the trouble of implementing this just for me to be able to write |
This was a question posed here #288 (comment)
The text was updated successfully, but these errors were encountered: