-
Notifications
You must be signed in to change notification settings - Fork 359
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
Should Dict.keys return a Set? #317
Comments
It's this way based on what I was used to in Haskell, so not the best reasoning. Best argument I can come up with is that typically I want the keys as a list if I am asking for them. Probably should look at uses of this function in the wild and see how many would be better if it was a set. Did this come up for you in a particular scenario? |
Yeah, I have a couple of Since I have to give the server a list of unique ids, I end up calling It's barely an inconvenience, but it surprised me because I'm used to Java, which only offers the |
Maybe there should be a choice. The default |
Well, I'm with Richard here, that the And if one wants a list, that functionality is already there (with |
So I think this idea makes sense, but I'd want to do a comprehensive overhaul of core APIs all at once. We are starting to see some ideas of how we can break things up or make the core data structures work together better, so I'd like to aggregate all those ideas and sort out how to combine them. I have been talking to a bunch of folks who maintain open source projects and learned some tricks about closing issues more efficiently, even when it's a good idea that we should revisit at a later time. So I want to start closing issues like this and moving the most promising ones to #322 so we can do a comprehensive review when it's time. |
Love it! 👍 |
So I know I'm late to this party, but I was thinking: since Dicts and Sets have the same representation except that a set never looks at the values, would it work to just hand the same dict object over and say it's a set? That way this function could run in O(1) rather than O(n) time. I don't think this is possible to implement because Dicts are actual Elm, not a native library, but in theory... |
Bonus! :D On Sun, Nov 8, 2015, 9:29 PM Max Goldstein [email protected] wrote:
|
Dict.keys
has this signature:It seems like
Set
would make more sense for the return type thanList
, as the keys in aDict
are:...whereas the elements in a
List
are ordered and not necessarily unique.The text was updated successfully, but these errors were encountered: