diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2012-12-14 17:37:25 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2012-12-14 17:37:39 +0000 |
commit | faa8ff40162da23a57b58fc128b0d672a8107a46 (patch) | |
tree | 7561f71178e8b7c6bca8313434943951d97d5983 /compiler/deSugar | |
parent | 566920c77bce252d807e9a7cc3da862e5817d340 (diff) | |
download | haskell-faa8ff40162da23a57b58fc128b0d672a8107a46.tar.gz |
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.
Diffstat (limited to 'compiler/deSugar')
-rw-r--r-- | compiler/deSugar/DsMeta.hs | 6 | ||||
-rw-r--r-- | compiler/deSugar/DsUtils.lhs | 12 |
2 files changed, 11 insertions, 7 deletions
diff --git a/compiler/deSugar/DsMeta.hs b/compiler/deSugar/DsMeta.hs index 405b7687a5..f25039c8a9 100644 --- a/compiler/deSugar/DsMeta.hs +++ b/compiler/deSugar/DsMeta.hs @@ -519,9 +519,9 @@ repBangTy ty= do rep2 strictTypeName [s, t] where (str, ty') = case ty of - L _ (HsBangTy HsUnpack ty) -> (unpackedName, ty) - L _ (HsBangTy _ ty) -> (isStrictName, ty) - _ -> (notStrictName, ty) + L _ (HsBangTy (HsBang True) ty) -> (unpackedName, ty) + L _ (HsBangTy _ ty) -> (isStrictName, ty) + _ -> (notStrictName, ty) ------------------------------------------------------- -- Deriving clause diff --git a/compiler/deSugar/DsUtils.lhs b/compiler/deSugar/DsUtils.lhs index 609041ba24..504a76dc86 100644 --- a/compiler/deSugar/DsUtils.lhs +++ b/compiler/deSugar/DsUtils.lhs @@ -316,10 +316,14 @@ mkCoAlgCaseMatchResult dflags var ty match_alts mk_case fail = do alts <- mapM (mk_alt fail) sorted_alts return (mkWildCase (Var var) (idType var) ty (mk_default fail ++ alts)) - mk_alt fail (con, args, MatchResult _ body_fn) = do - body <- body_fn fail - us <- newUniqueSupply - return (mkReboxingAlt (uniqsFromSupply us) con args body) + mk_alt fail (con, args, MatchResult _ body_fn) + = do { body <- body_fn fail + ; case dataConBoxer con of { + Nothing -> return (DataAlt con, args, body) ; + Just (DCB boxer) -> + do { us <- newUniqueSupply + ; let (rep_ids, binds) = initUs_ us (boxer ty_args args) + ; return (DataAlt con, rep_ids, mkLets binds body) } } } mk_default fail | exhaustive_case = [] | otherwise = [(DEFAULT, [], fail)] |