Commit 307ea550 authored by simonpj@microsoft.com's avatar simonpj@microsoft.com
Browse files

Newtype data constructors get a compulsory unfolding

With this change, newtype data constructors get a "compulsory" unfolding,
which means that they *must* be inlined, and no top-level definition of
the constructor is provided at all.  Since these constructors are no-ops,
I'm not sure why this wasn't the case all along.
parent 5abdfc85
......@@ -452,9 +452,11 @@ dataConWorkId dc = case dcIds dc of
NewDC _ -> pprPanic "dataConWorkId" (ppr dc)
dataConWrapId_maybe :: DataCon -> Maybe Id
-- Returns Nothing if there is no wrapper for an algebraic data con
-- and also for a newtype (whose constructor is inlined compulsorily)
dataConWrapId_maybe dc = case dcIds dc of
AlgDC mb_wrap _ -> mb_wrap
NewDC wrap -> Just wrap
NewDC wrap -> Nothing
dataConWrapId :: DataCon -> Id
-- Returns an Id which looks like the Haskell-source constructor
......
......@@ -252,7 +252,7 @@ mkDataConIds wrap_name wkr_name data_con
isSingleton orig_arg_tys )
-- No existentials on a newtype, but it can have a context
-- e.g. newtype Eq a => T a = MkT (...)
mkTopUnfolding $ Note InlineMe $
mkCompulsoryUnfolding $
mkLams tyvars $ Lam id_arg1 $
mkNewTypeBody tycon result_ty (Var id_arg1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment