Skip to content

association set conversions for Data.Map types #391

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

Closed
matthewleon opened this issue Feb 6, 2017 · 4 comments
Closed

association set conversions for Data.Map types #391

matthewleon opened this issue Feb 6, 2017 · 4 comments

Comments

@matthewleon
Copy link

Two things here:

toSet: It seems to me that an association set better embodies the static guarantees that we get when converting a map to an ascending association list with toAscList.

fromSet: It would also seem (naively) to me that this allows us to rely on the type system to produce the guarantee we want in fromAscList.

My apologies if this has been addressed elsewhere. I looked and couldn't find anything.

@treeowl
Copy link
Contributor

treeowl commented Feb 6, 2017 via email

@matthewleon
Copy link
Author

matthewleon commented Feb 6, 2017

toSet :: Map k a -> Set (k, a).
Convert the map to a set of key/value pairs.
The existing toAscList essentially does this, but without the static guarantee provided by the Set type that a key will not be repeated in the list. Admittedly, one could simply take the output of toAscList and build a Set with it, but my intuition (very possibly incorrect) is that there might be some optimization to exploit by writing this function intelligently.

fromSet :: Set (k, a) -> Map k a.
Build a map from a set of key/value pairs.
Similarly, we could do this by using fromAscList, but as its documentation states in italics, the precondition (input list is ascending) is not checked.

@treeowl
Copy link
Contributor

treeowl commented Feb 6, 2017 via email

@meooow25
Copy link
Contributor

This was addressed by #817

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

No branches or pull requests

5 participants