Skip to content
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

Unreliable set of sets #156

Open
timjs opened this issue May 8, 2023 · 2 comments
Open

Unreliable set of sets #156

timjs opened this issue May 8, 2023 · 2 comments

Comments

@timjs
Copy link

timjs commented May 8, 2023

As a consequence of universal equality in Unison, making a set of sets does not behave correctly:

s1 = List.range 1 10 |> Set.fromList
s2 = List.range 1 10 |> List.reverse |> Set.fromList

> s1 === s2 -- These are not equal, because the internal representation is different...

ss = Set.fromList [s1, s2]

> ss |> Set.size -- ... and therefore this returns `true`!

I know there is no easy solution for it now, but maybe we could add to the documentation of Set (and Map) that creating a set of sets won't work the way people expect due to implementation details.

@aryairani
Copy link
Contributor

Good catch, thanks @timjs

@aryairani aryairani transferred this issue from unisonweb/unison May 8, 2023
@ceedubs
Copy link
Contributor

ceedubs commented Aug 30, 2023

If you use Set.== instead of Universal.===, then s1 Set.== s2 does return true. However, I don't think that there's currently a good workaround for Set.fromList [s1, s2] returning a set with two elements.

This is an example of why #84 is needed.

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

No branches or pull requests

3 participants