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

Eq instance should imply substitutivity #18

Open
klntsky opened this issue Dec 28, 2018 · 0 comments
Open

Eq instance should imply substitutivity #18

klntsky opened this issue Dec 28, 2018 · 0 comments

Comments

@klntsky
Copy link

klntsky commented Dec 28, 2018

As stated here,

if x == y = True and f is a "public" function whose return type is an instance of Eq, then f x == f y = True

Currently we have, e.g.

>  fromList [1,2,3] == fromList [2,3,1]
True
> toList (fromList [1,2,3]) == toList (fromList [2,3,1])
False

I think that the Eq instance should be just derived and current implementation should be exported as separate function. Besides, using allRotations is surely not the most optimal way of implementing the desired behavior. What if two CLists contain different sets of elements? Current implementation will check all the rotations, while it is possible to return False after finding the first element which is present in one of the given CLists but not in the other.

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

1 participant