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

Filter implicit parameter instances from data-dependencies #7320

Merged
merged 2 commits into from
Sep 4, 2020

Conversation

cocreature
Copy link
Contributor

Occasionally GHC likes to float implicit parameters to the top-level
making them look like any other typeclass instances. Implicit
parameters are by design not unique so if we try to reconstruct them
we get an error about a duplicate instance.

I haven’t figured out when exactly GHC floats things to the top-level
but I did verify that this testcase breaks without the fix.

changelog_begin
changelog_end

Pull Request Checklist

  • Read and understand the contribution guidelines
  • Include appropriate tests
  • Set a descriptive title and thorough description
  • Add a reference to the issue this PR will solve, if appropriate
  • Include changelog additions in one or more commit message bodies between the CHANGELOG_BEGIN and CHANGELOG_END tags
  • Normal production system change, include purpose of change in description

NOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with /AzurePipelines run to
trigger the build.

Occasionally GHC likes to float implicit parameters to the top-level
making them look like any other typeclass instances. Implicit
parameters are by design not unique so if we try to reconstruct them
we get an error about a duplicate instance.

I haven’t figured out when exactly GHC floats things to the top-level
but I did verify that this testcase breaks without the fix.

changelog_begin
changelog_end
Copy link
Contributor

@sofiafaro-da sofiafaro-da left a comment

Choose a reason for hiding this comment

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

The fix looks good!

-- how to reliably stop it from doing this so be careful when changing this.
]
withCurrentDirectory (tmpDir </> "dep") $
callProcessSilent damlc ["build", "-o", "dep.dar"]
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can make a test that reliably generates an implicit parameter instance?

Or perhaps, add some a check to this test that an implicit parameter instance is in the DAR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I wonder if we can slip it in to the "Simple DALF" test or something. (It's not so simple...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’ve added an assertion that we have 2 implicit instances. Simple DALF would work as well I guess but this has the advantage that it tests what our users actually hit which seems useful. I still don’t understand how to generate it reliably. Even in this example you can remove the type signature, the inferred type stays the same but now it’s inlined 🤷

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome, thank you!

changelog_begin
changelog_end
@mergify mergify bot merged commit 0903b1a into master Sep 4, 2020
@mergify mergify bot deleted the filter-implicit branch September 4, 2020 07:36
Copy link
Contributor

@hurryabit hurryabit left a comment

Choose a reason for hiding this comment

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

This scares me a bit. But thanks a lot for the quick fix.

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.

3 participants