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

Refactor the hypothesis type in hls-tactics-plugin #1347

Merged
merged 12 commits into from Feb 11, 2021

Conversation

isovector
Copy link
Collaborator

@isovector isovector commented Feb 11, 2021

The Hypothesis is all of the values in scope that the tactics engine knows about. It used to be a Map OccName HyInfo, mapping names to the information we have about them. But this is unhelpful for two reasons:

  1. Almost nowhere in the code do we lookup by name
  2. Class methods get instantiated for every concrete type, meaning we couldn't have two givens for different types in scope

Worse, it actively encouraged a bad style where we'd iterate through the keys of the hypothesis, and then need to look up the value in the map we were iterating. All of these callsites have now been simplified to just take the HyInfo directly, rather than an OccName that we'd subsequently need to lookup.

This PR refactors some of the underlying machinery. It's a bit simplistic now, but paves the way for a smarter implementation when I figure out what it should look like. In the meantime, it means we can now solve goals like

fmapBoth :: (Functor f, Functor g) => (a -> b) -> (f a, g a) -> (f b, g b)
fmapBoth = _

since the fmaps for f and g no longer clash.

Copy link
Member

@jneira jneira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with the analysis and tests are green so lgtm

@jneira jneira added the merge me Label to trigger pull request merge label Feb 11, 2021
@mergify mergify bot merged commit 11d0d51 into haskell:master Feb 11, 2021
@isovector isovector deleted the refactor-hypothesis branch May 21, 2021 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Label to trigger pull request merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants