Skip to content

Conversation

@klntsky
Copy link
Contributor

@klntsky klntsky commented Jul 13, 2019

fix #395

@klntsky klntsky changed the title fix #395 Treat variables in type queries same as type wildcards Jul 13, 2019
@hdgarrood
Copy link
Collaborator

This change invalidates the above comment, right? Although perhaps the fact that #395 was opened in the first place suggests that having a query of a not match the type Int at all wasn't quite the right approach. How about considering it a match, but applying a larger penalty in this case? Say, 2?

@hdgarrood
Copy link
Collaborator

Hm, I suppose the current handling of TypeWildcard doesn't really match up with what the comment says.

@klntsky
Copy link
Contributor Author

klntsky commented Jul 13, 2019

Hm, I suppose the current handling of TypeWildcard doesn't really match up with what the comment says.

I believe the initial idea was that TypeWildcard in a query is a special case and should match any type without additional penalty aside of typeComplexity (typeComplexity is probably here to ensure that less hairy types appear higher in the results).

How about considering it a match, but applying a larger penalty in this case? Say, 2?

A greater penalty leads to this:

2019-07-13-213839_678x937_scrot.

IMO the penalty for instantiation should be lower than the penalty for generalization. What about multiplying everything by 2 and charging just 1 for instantiation?

@klntsky
Copy link
Contributor Author

klntsky commented Jul 13, 2019

One possible solution is to return negative numbers for exact matches of type constructors:

  go (P.TypeConstructor _ q1) (P.TypeConstructor _ q2) | compareQual q1 q2 = pure (-1)

@klntsky
Copy link
Contributor Author

klntsky commented Jul 15, 2019

As for now I updated the comment to reflect the intention behind the proposed fix (though the best way to resolve the issue is not clear IMO).

@hdgarrood hdgarrood mentioned this pull request Jul 7, 2020
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

Successfully merging this pull request may close these issues.

a -> HTMLElement and _ -> HTMLElement have different results

2 participants