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

Type equality logic is wrong #6

Open
acrylic-origami opened this issue Nov 16, 2019 · 0 comments
Open

Type equality logic is wrong #6

acrylic-origami opened this issue Nov 16, 2019 · 0 comments
Labels
bug Something isn't working

Comments

@acrylic-origami
Copy link
Owner

The type equality routine inst_subty was initially designed for finding instance methods, which could only be found by type comparison. Now, purebase is designed around the concept of type comparison rather than strict Unique matching because this way the types of built-in classes, especially Monad (and do blocks by association), are correct. Then, it's no longer accurate that a more concrete function is an admissible one. This is due to the interaction between contravariance and higher-rank types, such that something like forall a. (a -> a) -> a will work for a call to (Int -> Int) -> Int, but not (forall a. a -> a) -> b.

In general, this problem is hard. How do we know the variance of an arbitrary type constructor, like (forall a. c a)? How does a vary? Of course, between modules there may be many well-typed functions for callsites too, although outside of matching module names, this problem is unsolvable anyways.

I will admit that this is something of a corner case, as it assumes that there are many functions with the same name and very similar types that would fail this analysis. Even things like Data.Map.{...}.map vs. Prelude.map are different enough in signature for this current test to work at picking them apart.

@acrylic-origami acrylic-origami added the bug Something isn't working label Nov 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant