Attach warnings to non-PVP compatible uses of signatures.

Authored by ezyang on Dec 29 2016, 11:13 PM.



If you use an inherited signature from another package in your own code,
the only valid PVP bound you can specify for this package is an *exact*
version bound. This is because the signature is used both covariantly
(it provides declarations for import) and contravariantly (it specifies
what is required). However, this is a bit distressing if you want to
use a PVP-style bound that allows for upgrading a package. So there is
a dichotomy:

  1. Any signatures that come from packages with exact bounds (this includes, in particular, signature packages, who are included solely to make declarations available), can be used without problem by modules, but
  2. Any signatures that come from packages that are version bounded (i.e., any package that also provides modules) must NOT be used, because if they were used, they could break under a PVP policy that allows relaxations in the needed requirements.

To help users avoid situation (2), I've added a warning to all
signature declarations that come solely from (2). This is not
perfect; you might still end up relying on some type identity
specified by a signature in a version-bounded package, but it
should help catch major errors.

Signed-off-by: Edward Z. Yang <>

Test Plan


Diff Detail

rGHC Glasgow Haskell Compiler
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
ezyang updated this revision to Diff 10210.Dec 29 2016, 11:13 PM
ezyang retitled this revision from to Attach warnings to non-PVP compatible uses of signatures..
ezyang updated this object.
ezyang edited the test plan for this revision. (Show Details)
ezyang added a reviewer: simonpj.
bgamari requested changes to this revision.Jan 2 2017, 11:34 PM
bgamari edited edge metadata.

It looks like there are a few validation issues here, @ezyang. I've restarted the Linux build to ensure they are reproducible.

Also, don't we need some sort of documentation of this?


Could we do something about this line length? 315 characters is a bit absurd.


A comment (or perhaps even note) in here somewhere explaining what we are checking for would be helpful.


Should these quotes be here?

This revision now requires changes to proceed.Jan 2 2017, 11:34 PM
ezyang added inline comments.Jan 4 2017, 10:34 PM



Yeah, whenever you have a user-defined WARNING (which is the mechanism used here) the message is output in quotes. I've always thought it was quirky (but harmless.)

Yeah, I have a big documentation patch cooking, but it rolls up all the behavior changes from these patches.

ezyang updated this revision to Diff 10253.Jan 4 2017, 11:00 PM
ezyang edited edge metadata.
ezyang marked 3 inline comments as done.

Address comments.

bgamari accepted this revision.Jan 9 2017, 7:28 PM
bgamari edited edge metadata.

This looks good to me.

This revision is now accepted and ready to land.Jan 9 2017, 7:28 PM
This revision was automatically updated to reflect the committed changes.