Refactor and improve the promotion inference
authorSimon Peyton Jones <simonpj@microsoft.com>
Fri, 25 Jan 2013 12:48:06 +0000 (12:48 +0000)
committerSimon Peyton Jones <simonpj@microsoft.com>
Fri, 25 Jan 2013 12:48:06 +0000 (12:48 +0000)
commit09ff0e0da88272fa4a8f117bbc90cea9e444ab5d
tree039d283034b2689b8447cbb831ff8ac13891cd88
parent35f1fc957d152c520c90c6bd2330266e57578eb2
Refactor and improve the promotion inference

It should be the case that either an entire mutually recursive
group of data type declarations can be promoted, or none of them.
It's really odd to promote some data constructors of a type but
not others. Eg
  data T a = T1 a | T2 Int
Here T1 is sort-of-promotable but T2 isn't (becuase Int isn't
promotable).

This patch makes it all-or-nothing. At the same time I've made
the TyCon point to its promoted cousin (via the tcPromoted field
of an AlgTyCon), as well as vice versa (via the ty_con field of
PromotedTyCon).

The inference for the group is done in TcTyDecls, the same place
that infers which data types are recursive, another global question.
15 files changed:
compiler/basicTypes/DataCon.lhs
compiler/iface/BinIface.hs
compiler/iface/BuildTyCl.lhs
compiler/iface/IfaceSyn.lhs
compiler/iface/MkIface.lhs
compiler/iface/TcIface.lhs
compiler/prelude/TysWiredIn.lhs
compiler/typecheck/TcGenGenerics.lhs
compiler/typecheck/TcHsType.lhs
compiler/typecheck/TcInstDcls.lhs
compiler/typecheck/TcTyClsDecls.lhs
compiler/typecheck/TcTyDecls.lhs
compiler/types/TyCon.lhs
compiler/vectorise/Vectorise/Generic/PData.hs
compiler/vectorise/Vectorise/Type/TyConDecl.hs