Rework derivation of type representations for wired-in things
authorBen Gamari <bgamari.foss@gmail.com>
Wed, 20 Jan 2016 15:06:31 +0000 (16:06 +0100)
committerBen Gamari <ben@smart-cactus.org>
Wed, 20 Jan 2016 16:08:05 +0000 (17:08 +0100)
commit84b0ebedd09fcfbda8efd7576dce9f52a2b6e6ca
tree3a40ac5518869947bf98bf1451b1915d75ffbe81
parent5cce09543db827e662539523ffff4513deb92777
Rework derivation of type representations for wired-in things

Previously types defined by `GHC.Types` and `GHC.Prim` had their
`Typeable` representations manually defined in `GHC.Typeable.Internals`.
This was terrible, resulting in a great deal of boilerplate and a number
of bugs due to missing or inconsistent representations (see #11120).

Here we take a different tack, initially proposed by Richard Eisenberg:
We wire-in the `Module`, `TrName`, and `TyCon` types, allowing them to
be used in `GHC.Types`. We then allow the usual type representation
generation logic to handle this module.

`GHC.Prim`, on the other hand, is a bit tricky as it has no object code
of its own.  To handle this we instead place the type representations
for the types defined here in `GHC.Types`.

On the whole this eliminates several special-cases as well as a fair
amount of boilerplate from hand-written representations. Moreover, we
get full coverage of primitive types for free.

Test Plan: Validate

Reviewers: goldfire, simonpj, austin, hvr

Subscribers: goldfire, simonpj, thomie

Differential Revision: https://phabricator.haskell.org/D1774

GHC Trac Issues: #11120
16 files changed:
compiler/basicTypes/OccName.hs
compiler/basicTypes/Unique.hs
compiler/iface/BuildTyCl.hs
compiler/prelude/PrelNames.hs
compiler/prelude/TysPrim.hs
compiler/prelude/TysWiredIn.hs
compiler/typecheck/TcRnDriver.hs
compiler/typecheck/TcTypeable.hs
compiler/types/TyCon.hs
compiler/vectorise/Vectorise/Type/TyConDecl.hs
libraries/base/Data/Typeable/Internal.hs
libraries/ghc-prim/GHC/Types.hs
testsuite/tests/ghci.debugger/scripts/print019.stderr
testsuite/tests/typecheck/should_run/T11120.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_run/T11120.stdout [new file with mode: 0644]
testsuite/tests/typecheck/should_run/all.T