Custom `Typeable` solver, that keeps track of kinds.
ClosedPublic

Authored by yav on Feb 11 2015, 5:32 PM.

Details

Summary

This implements the new Typeable solver: when GHC sees Typeable constraints
it solves them on the spot.

The current implementation creates TyCon representations on the spot.

Pro: No overhead at all in code that does not use Typeable
Cons: Code that uses Typeable may create multipe TyCon represntations.

We have discussed an implementation where representations of TyCons are
computed once, in the module, where a datatype is declared. This would
lead to more code being generated: for a promotable datatype we need to
generate 2 + number_of_data_cons type-constructro representations,
and we have to do that for all programs, even ones that do not intend to
use typeable.

I added code to emit warning whenevar deriving Typeable is encountered---
the idea being that this is not needed anymore, and shold be fixed.

Also, we allow instance Typeable T in .hs-boot files, but they result
in a warning, and are ignored. This last one was to avoid breaking exisitng
code, and should become an error, eventually.

Test Plan
  1. GHC can compile itself.
  2. I compiled a number of large libraries, including lens.
    • I had to make some small changes: unordered-containers uses internals of TypeReps, so I had to do a 1 line fix
    • lens needed one instance changed, due to a poly-kinded Typeble instance
  1. I also run some code that uses syb to traverse a largish datastrucutre.

I didn't notice any signifiant performance difference between the 7.8.3 version,
and this implementation.

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
yav updated this revision to Diff 2220.Feb 11 2015, 5:32 PM
yav retitled this revision from to Custom `Typeable` solver, that keeps track of kinds..
yav updated this object.
yav edited the test plan for this revision. (Show Details)
yav added reviewers: simonpj, austin, simonmar.
yav updated the Trac tickets for this revision.
yav added a comment.Feb 11 2015, 7:17 PM

Apologies for the noise: this version had a bug, which I've now fixed on my branch, but I don't know how to regenarate the arc. Advice?

In the meantime: I also disabled the warnings about "ignoring deriving Typeable", as they lead to failure with -Wall, and I don't have time at the moment to update all of base, and GHC's dependencies. Perhaps, it'd be better to make this warning controllable with a switch.

Most of the fast validate passes, however there are a few tests that fail, and I am looking into the reason for that.

simonmar edited edge metadata.Feb 12 2015, 8:59 AM

Did you look at code size differences? I worry that this might be worse than deriving Typeable everywhere.

yav updated this revision to Diff 2222.Feb 12 2015, 12:29 PM
yav edited edge metadata.
  • Remove more unused code.
  • Bugfix: proxy# needs a kind, as well as a type.
  • Disable Ignoring derive Typeable warnings.
  • Remove unused imports to prevent warning, which leads to validation failure.
yav updated this revision to Diff 2228.Feb 12 2015, 7:07 PM
  • Add flag to warn when deriving typeable, and update user manual
hvr requested changes to this revision.Mar 5 2015, 2:57 AM
hvr edited edge metadata.

D699 should go in first, so we can avoid having to update deepseq as part of *this* change

This revision now requires changes to proceed.Mar 5 2015, 2:57 AM
hvr accepted this revision.Mar 6 2015, 11:11 AM
hvr edited edge metadata.

well... D699 went in...

This revision is now accepted and ready to land.Mar 6 2015, 11:11 AM
austin accepted this revision.Mar 7 2015, 10:36 AM
austin edited edge metadata.

Validate is passing and everything. Pushing now...

austin edited the test plan for this revision. (Show Details)Mar 7 2015, 10:38 AM
austin edited edge metadata.
This revision was automatically updated to reflect the committed changes.