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

API Suggestion - custom compare-functions for dict/set #947

Closed
opvasger opened this Issue Mar 6, 2018 · 6 comments

Comments

Projects
None yet
3 participants
@opvasger

opvasger commented Mar 6, 2018

I've been reading through a lot of the discussion of comparison in Elm; My particular problem with comparison is that I often want to use unions as keys in sets & dicts.

An approach I haven't read about so far would be to change the signature of the functions that construct Sets and Dicts. For example:

Dict.empty : ( k → k → Basics.Order )Dict k v

Simply provide a comparison instead of using Basics.compare. There's a lot of flexibility to this, and you can have the old behavior by simply passing Basics.compare as the first argument to these constructing functions.

The API changes I'm suggesting required to do this are obvious: all constructing functions for the collections would need to take a comparison function as it's first input, and quite a few functions would have to exchange their comparable input signatures for a type variable

Even if the current signatures are considered more friendly, one could make the implementation detail of having the Dict / Set carry the comparison function of the before-mentioned signature and then simply expose, for example, empty or singleton with Basics.compare partially applied.

@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

process-bot Mar 6, 2018

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

process-bot commented Mar 6, 2018

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@opvasger

This comment has been minimized.

Show comment
Hide comment
@opvasger

opvasger Mar 7, 2018

I do not want to track feature requests in issues for a couple reasons:

Rather than focusing on things that could be better, I am prioritizing things that cannot be done. In this case, the workaround is creating new definitions and type aliases. So this can be done, but could be better.
Feedback online is not representative of Elm users. The fraction of people using Elm who will never give feedback through a GitHub issue is certainly higher than 90%. So like in normal products, doing user studies is a better way to gather feedback.
If a feature request is "alright" it can sit around for a long time, cluttering up all the other issues that are related to bugs. Having it open or closed does not change whether we can look back at it though.
So for those reasons, I am closing this. We can still refer back to it at an appropriate time.

Based on reading you write this in another issue, I will close this issue, and find a more suitable place to post. I apologize for the noise

opvasger commented Mar 7, 2018

I do not want to track feature requests in issues for a couple reasons:

Rather than focusing on things that could be better, I am prioritizing things that cannot be done. In this case, the workaround is creating new definitions and type aliases. So this can be done, but could be better.
Feedback online is not representative of Elm users. The fraction of people using Elm who will never give feedback through a GitHub issue is certainly higher than 90%. So like in normal products, doing user studies is a better way to gather feedback.
If a feature request is "alright" it can sit around for a long time, cluttering up all the other issues that are related to bugs. Having it open or closed does not change whether we can look back at it though.
So for those reasons, I am closing this. We can still refer back to it at an appropriate time.

Based on reading you write this in another issue, I will close this issue, and find a more suitable place to post. I apologize for the noise

@opvasger opvasger closed this Mar 7, 2018

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Mar 7, 2018

Member

No need to apologize! I have a rather unconventional view on these sorts of things, and it seems like different assumptions are literally built in to GitHub, so it makes sense that people are surprised by the preferences here. I'll be working on communicating these things better in the future though!

Member

evancz commented Mar 7, 2018

No need to apologize! I have a rather unconventional view on these sorts of things, and it seems like different assumptions are literally built in to GitHub, so it makes sense that people are surprised by the preferences here. I'll be working on communicating these things better in the future though!

@opvasger

This comment has been minimized.

Show comment
Hide comment
@opvasger

opvasger Mar 7, 2018

Alright - I'll put this on Discourse instead; It seems like a better place for a debat on the merits of my argument.

opvasger commented Mar 7, 2018

Alright - I'll put this on Discourse instead; It seems like a better place for a debat on the merits of my argument.

@opvasger

This comment has been minimized.

Show comment
Hide comment
@opvasger

opvasger Mar 7, 2018

@evancz I think I just crashed the discourse site posting it - I embedded from Ellie as part of my post, and I'm assuming that's the cause.

opvasger commented Mar 7, 2018

@evancz I think I just crashed the discourse site posting it - I embedded from Ellie as part of my post, and I'm assuming that's the cause.

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Mar 7, 2018

Member

It seems like it is working to me. I see the post at least!

Member

evancz commented Mar 7, 2018

It seems like it is working to me. I see the post at least!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment