• Simon Peyton Jones's avatar
    Major refactoring of the way that UNPACK pragmas are handled · faa8ff40
    Simon Peyton Jones authored
    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.
DsUtils.lhs 27.9 KB