Major refactoring of the way that UNPACK pragmas are handled
authorSimon Peyton Jones <simonpj@microsoft.com>
Fri, 14 Dec 2012 17:37:25 +0000 (17:37 +0000)
committerSimon Peyton Jones <simonpj@microsoft.com>
Fri, 14 Dec 2012 17:37:39 +0000 (17:37 +0000)
commitfaa8ff40162da23a57b58fc128b0d672a8107a46
tree7561f71178e8b7c6bca8313434943951d97d5983
parent566920c77bce252d807e9a7cc3da862e5817d340
Major refactoring of the way that UNPACK pragmas are handled

The situation was pretty dire.  The way in which data constructors
were handled, notably the mapping between their *source* argument types
and their *representation* argument types (after seq'ing and unpacking)
was scattered in three different places, and hard to keep in sync.

Now it is all in one place:

 * The dcRep field of a DataCon gives its representation,
   specified by a DataConRep

 * As well as having the wrapper, the DataConRep has a "boxer"
   of type DataConBoxer (defined in MkId for loopy reasons).
   The boxer used at a pattern match to reconstruct the source-level
   arguments from the rep-level bindings in the pattern match.

 * The unboxing in the wrapper and the boxing in the boxer are dual,
   and are now constructed together, by MkId.mkDataConRep. This is
   the key function of this change.

 * All the computeBoxingStrategy code in TcTyClsDcls disappears.

Much nicer.

There is a little bit of refactoring left to do; the strange
deepSplitProductType functions are now called only in WwLib, so
I moved them there, and I think they could be tidied up further.
18 files changed:
compiler/basicTypes/BasicTypes.lhs
compiler/basicTypes/DataCon.lhs
compiler/basicTypes/DataCon.lhs-boot
compiler/basicTypes/MkId.lhs
compiler/basicTypes/MkId.lhs-boot
compiler/deSugar/DsMeta.hs
compiler/deSugar/DsUtils.lhs
compiler/hsSyn/Convert.lhs
compiler/iface/BinIface.hs
compiler/iface/BuildTyCl.lhs
compiler/iface/MkIface.lhs
compiler/main/DynFlags.hs
compiler/parser/Parser.y.pp
compiler/prelude/TysWiredIn.lhs
compiler/stranal/WwLib.lhs
compiler/typecheck/TcInstDcls.lhs
compiler/typecheck/TcTyClsDecls.lhs
compiler/types/TyCon.lhs