Commit 42b63073 authored by simonpj's avatar simonpj

[project @ 2003-02-12 15:01:31 by simonpj]

-------------------------------------
  Big upheaval to the way that constructors are named
	-------------------------------------

This commit enshrines the new story for constructor names.  We could never
really get External Core to work nicely before, but now it does.

The story is laid out in detail in the Commentary
	ghc/docs/comm/the-beast/data-types.html
so I will not repeat it here.

	[Manuel: the commentary isn't being updated, apparently.]

However, the net effect is that in Core and in External Core, contructors look
like constructors, and the way things are printed is all consistent.

It is a fairly pervasive change (which is why it has been so long postponed),
but I hope the question is now finally closed.

All the libraries compile etc, and I've run many tests, but doubtless there will
be some dark corners.
parent 87bfa396
......@@ -43,7 +43,6 @@ import FiniteMap ( addToFM, emptyFM, lookupFM, FiniteMap )
import Literal ( Literal(..) )
import TyCon ( tyConDataCons )
import Name ( NamedThing(..) )
import DataCon ( dataConWrapId )
import Maybes ( catMaybes )
import PrimOp ( primOpNeedsWrapper )
import MachOp ( MachOp(..) )
......@@ -473,7 +472,7 @@ pprAbsC stmt@(CClosureTbl tycon) _
ptext SLIT("CLOSURE_TBL") <>
lparen <> pprCLabel (mkClosureTblLabel tycon) <> rparen :
punctuate comma (
map (pp_closure_lbl . mkClosureLabel . getName . dataConWrapId) (tyConDataCons tycon)
map (pp_closure_lbl . mkClosureLabel . getName) (tyConDataCons tycon)
)
) $$ ptext SLIT("};")
......
module DataCon where
data DataCon
dataConRepType :: DataCon -> TypeRep.Type
isExistentialDataCon :: DataCon -> GHC.Base.Bool
......@@ -13,7 +13,9 @@ module DataCon (
dataConRepArgTys, dataConTheta,
dataConFieldLabels, dataConStrictMarks,
dataConSourceArity, dataConRepArity,
dataConNumInstArgs, dataConWorkId, dataConWrapId, dataConRepStrictness,
dataConNumInstArgs,
dataConWorkId, dataConWrapId, dataConWrapId_maybe,
dataConRepStrictness,
isNullaryDataCon, isTupleCon, isUnboxedTupleCon,
isExistentialDataCon, classDataCon, dataConExistentialTyVars,
......@@ -40,27 +42,79 @@ import BasicTypes ( Arity, StrictnessMark(..) )
import Outputable
import Unique ( Unique, Uniquable(..) )
import CmdLineOpts ( opt_UnboxStrictFields )
import Maybe
import Maybes ( orElse )
import ListSetOps ( assoc )
import Util ( zipEqual, zipWithEqual, equalLength, notNull )
\end{code}
Stuff about data constructors
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Every constructor, C, comes with a
Data constructor representation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider the following Haskell data type declaration
*wrapper*, called C, whose type is exactly what it looks like
in the source program. It is an ordinary function,
and it gets a top-level binding like any other function
data T = T !Int ![Int]
Using the strictness annotations, GHC will represent this as
data T = T Int# [Int]
That is, the Int has been unboxed. Furthermore, the Haskell source construction
T e1 e2
is translated to
case e1 of { I# x ->
case e2 of { r ->
T x r }}
That is, the first argument is unboxed, and the second is evaluated. Finally,
pattern matching is translated too:
case e of { T a b -> ... }
becomes
case e of { T a' b -> let a = I# a' in ... }
To keep ourselves sane, we name the different versions of the data constructor
differently, as follows.
Note [Data Constructor Naming]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Each data constructor C has two, and possibly three, Names associated with it:
*worker*, called $wC, which is the actual data constructor.
Its type may be different to C, because:
OccName Name space Used for
---------------------------------------------------------------------------
* The "source data con" C DataName The DataCon itself
* The "real data con" C VarName Its worker Id
* The "wrapper data con" $wC VarName Wrapper Id (optional)
Each of these three has a distinct Unique. The "source data con" name
appears in the output of the renamer, and names the Haskell-source
data constructor. The type checker translates it into either the wrapper Id
(if it exists) or worker Id (otherwise).
The data con has one or two Ids associated with it:
The "worker Id", is the actual data constructor.
Its type may be different to the Haskell source constructor
because:
- useless dict args are dropped
- strict args may be flattened
It does not have a binding.
The worker is very like a primop, in that it has no binding.
Newtypes currently do get a worker-Id, but it is never used.
The "wrapper Id", $wC, whose type is exactly what it looks like
in the source program. It is an ordinary function,
and it gets a top-level binding like any other function.
The wrapper Id isn't generated for a data type if the worker
and wrapper are identical. It's always generated for a newtype.
The worker is very like a primop, in that it has no binding,
A note about the stupid context
......@@ -109,7 +163,8 @@ in an expression or in a pattern.
data DataCon
= MkData { -- Used for data constructors only;
-- there *is* no constructor for a newtype
dcName :: Name,
dcName :: Name,
dcUnique :: Unique, -- Cached from Name
dcTag :: ConTag,
......@@ -155,7 +210,7 @@ data DataCon
-- "Stupid", because the dictionaries aren't used for anything.
--
-- Indeed, [as of March 02] they are no
-- longer in the type of the dataConWrapId, because
-- longer in the type of the dcWrapId, because
-- that makes it harder to use the wrap-id to rebuild
-- values after record selection or in generics.
......@@ -194,8 +249,11 @@ data DataCon
dcWorkId :: Id, -- The corresponding worker Id
-- Takes dcRepArgTys as its arguments
-- Perhaps this should be a 'Maybe'; not reqd for newtype constructors
dcWrapId :: Id -- The wrapper Id
dcWrapId :: Maybe Id -- The wrapper Id, if it's necessary
-- It's deemed unnecessary if it performs the
-- identity function
}
type ConTag = Int
......@@ -260,25 +318,24 @@ instance Show DataCon where
%************************************************************************
\begin{code}
mkDataCon :: Name
mkDataCon :: Name
-> [StrictnessMark] -> [FieldLabel]
-> [TyVar] -> ThetaType
-> [TyVar] -> ThetaType
-> [Type] -> TyCon
-> Id -> Id
-> Id -> Maybe Id -- Worker and possible wrapper
-> DataCon
-- Can get the tag from the TyCon
mkDataCon name arg_stricts fields
mkDataCon name
arg_stricts -- Use [] to mean 'all non-strict'
fields
tyvars theta ex_tyvars ex_theta orig_arg_tys tycon
work_id wrap_id
= ASSERT(equalLength arg_stricts orig_arg_tys)
-- The 'stricts' passed to mkDataCon are simply those for the
-- source-language arguments. We add extra ones for the
-- dictionary arguments right here.
con
= con
where
con = MkData {dcName = name, dcUnique = nameUnique name,
con = MkData {dcName = name,
dcUnique = nameUnique name,
dcTyVars = tyvars, dcStupidTheta = theta,
dcOrigArgTys = orig_arg_tys,
dcRepArgTys = rep_arg_tys,
......@@ -290,10 +347,15 @@ mkDataCon name arg_stricts fields
-- Strictness marks for source-args
-- *after unboxing choices*,
-- but *including existential dictionaries*
--
-- The 'arg_stricts' passed to mkDataCon are simply those for the
-- source-language arguments. We add extra ones for the
-- dictionary arguments right here.
ex_dict_tys = mkPredTys ex_theta
real_stricts = (map mk_dict_strict_mark ex_dict_tys) ++
zipWithEqual "mkDataCon1" (chooseBoxingStrategy tycon)
orig_arg_tys arg_stricts
real_stricts = map mk_dict_strict_mark ex_dict_tys ++
zipWith (chooseBoxingStrategy tycon)
orig_arg_tys
(arg_stricts ++ repeat NotMarkedStrict)
real_arg_tys = ex_dict_tys ++ orig_arg_tys
-- Representation arguments and demands
......@@ -326,8 +388,14 @@ dataConRepType = dcRepType
dataConWorkId :: DataCon -> Id
dataConWorkId = dcWorkId
dataConWrapId_maybe :: DataCon -> Maybe Id
dataConWrapId_maybe = dcWrapId
dataConWrapId :: DataCon -> Id
dataConWrapId = dcWrapId
-- Returns an Id which looks like the Haskell-source constructor
-- If there is no dcWrapId it's because there is no need for a
-- wrapper, so the worker is the Right Thing
dataConWrapId dc = dcWrapId dc `orElse` dcWorkId dc
dataConFieldLabels :: DataCon -> [FieldLabel]
dataConFieldLabels = dcFields
......
......@@ -29,7 +29,7 @@ module Id (
isRecordSelector,
isPrimOpId, isPrimOpId_maybe,
isFCallId, isFCallId_maybe,
isDataConId, isDataConId_maybe,
isDataConWorkId, isDataConWorkId_maybe,
isDataConWrapId, isDataConWrapId_maybe,
isBottomingId,
hasNoBinding,
......@@ -257,13 +257,13 @@ isFCallId_maybe id = case globalIdDetails id of
FCallId call -> Just call
other -> Nothing
isDataConId id = case globalIdDetails id of
DataConId _ -> True
other -> False
isDataConWorkId id = case globalIdDetails id of
DataConWorkId _ -> True
other -> False
isDataConId_maybe id = case globalIdDetails id of
DataConId con -> Just con
other -> Nothing
isDataConWorkId_maybe id = case globalIdDetails id of
DataConWorkId con -> Just con
other -> Nothing
isDataConWrapId_maybe id = case globalIdDetails id of
DataConWrapId con -> Just con
......@@ -292,7 +292,7 @@ isImplicitId id
RecordSelId _ -> True -- Includes dictionary selectors
FCallId _ -> True
PrimOpId _ -> True
DataConId _ -> True
DataConWorkId _ -> True
DataConWrapId _ -> True
-- These are are implied by their type or class decl;
-- remember that all type and class decls appear in the interface file.
......
......@@ -235,7 +235,7 @@ data GlobalIdDetails
= VanillaGlobal -- Imported from elsewhere, a default method Id.
| RecordSelId FieldLabel -- The Id for a record selector
| DataConId DataCon -- The Id for a data constructor *worker*
| DataConWorkId DataCon -- The Id for a data constructor *worker*
| DataConWrapId DataCon -- The Id for a data constructor *wrapper*
-- [the only reasons we need to know is so that
-- a) we can suppress printing a definition in the interface file
......@@ -252,7 +252,7 @@ notGlobalId = NotGlobalId
instance Outputable GlobalIdDetails where
ppr NotGlobalId = ptext SLIT("[***NotGlobalId***]")
ppr VanillaGlobal = ptext SLIT("[GlobalId]")
ppr (DataConId _) = ptext SLIT("[DataCon]")
ppr (DataConWorkId _) = ptext SLIT("[DataCon]")
ppr (DataConWrapId _) = ptext SLIT("[DataConWrapper]")
ppr (PrimOpId _) = ptext SLIT("[PrimOp]")
ppr (FCallId _) = ptext SLIT("[ForeignCall]")
......
module MkId where
mkDataConId :: Name.Name -> DataCon.DataCon -> Var.Id
mkDataConWrapId :: DataCon.DataCon -> Var.Id
mkDataConWorkId :: Name.Name -> DataCon.DataCon -> Var.Id
......@@ -16,7 +16,7 @@ module MkId (
mkDictFunId, mkDefaultMethodId,
mkDictSelId,
mkDataConId, mkDataConWrapId,
mkDataConWorkId, mkDataConWrapId,
mkRecordSelId,
mkPrimOpId, mkFCallId,
......@@ -64,7 +64,7 @@ import DataCon ( DataCon,
dataConFieldLabels, dataConRepArity, dataConTyCon,
dataConArgTys, dataConRepType,
dataConOrigArgTys,
dataConName, dataConTheta,
dataConTheta,
dataConSig, dataConStrictMarks, dataConWorkId,
splitProductType
)
......@@ -149,18 +149,18 @@ ghcPrimIds
%************************************************************************
\begin{code}
mkDataConId :: Name -> DataCon -> Id
mkDataConWorkId :: Name -> DataCon -> Id
-- Makes the *worker* for the data constructor; that is, the function
-- that takes the reprsentation arguments and builds the constructor.
mkDataConId work_name data_con
= mkGlobalId (DataConId data_con) work_name (dataConRepType data_con) info
mkDataConWorkId wkr_name data_con
= mkGlobalId (DataConWorkId data_con) wkr_name
(dataConRepType data_con) info
where
info = noCafIdInfo
`setArityInfo` arity
`setAllStrictnessInfo` Just strict_sig
arity = dataConRepArity data_con
strict_sig = mkStrictSig (mkTopDmdType (replicate arity topDmd) cpr_info)
-- Notice that we do *not* say the worker is strict
-- even if the data constructor is declared strict
......@@ -237,18 +237,40 @@ Notice that
it in the (common) case where the constructor arg is already evaluated.
\begin{code}
mkDataConWrapId data_con
= mkGlobalId (DataConWrapId data_con) (dataConName data_con) wrap_ty info
mkDataConWrapId :: Name -> DataCon -> Maybe Id
-- Only make a wrapper Id if necessary
mkDataConWrapId wrap_name data_con
| is_newtype || any isMarkedStrict strict_marks
= -- We need a wrapper function
Just (mkGlobalId (DataConWrapId data_con) wrap_name wrap_ty info)
| otherwise
= Nothing -- The common case, where there is no point in
-- having a wrapper function. Not only is this efficient,
-- but it also ensures that the wrapper is replaced
-- by the worker (becuase it *is* the wroker)
-- even when there are no args. E.g. in
-- f (:) x
-- the (:) *is* the worker.
-- This is really important in rule matching,
-- (We could match on the wrappers,
-- but that makes it less likely that rules will match
-- when we bring bits of unfoldings together.)
where
work_id = dataConWorkId data_con
(tyvars, _, ex_tyvars, ex_theta, orig_arg_tys, tycon) = dataConSig data_con
is_newtype = isNewTyCon tycon
all_tyvars = tyvars ++ ex_tyvars
work_id = dataConWorkId data_con
info = noCafIdInfo
`setUnfoldingInfo` wrap_unf
-- The NoCaf-ness is set by noCafIdInfo
`setArityInfo` arity
common_info = noCafIdInfo -- The NoCaf-ness is set by noCafIdInfo
`setArityInfo` arity
-- It's important to specify the arity, so that partial
-- applications are treated as values
`setAllStrictnessInfo` Just wrap_sig
info | is_newtype = common_info `setUnfoldingInfo` newtype_unf
| otherwise = common_info `setUnfoldingInfo` data_unf
`setAllStrictnessInfo` Just wrap_sig
wrap_sig = mkStrictSig (mkTopDmdType arg_dmds res_info)
res_info = strictSigResInfo (idNewStrictness work_id)
......@@ -264,35 +286,15 @@ mkDataConWrapId data_con
-- ...(let w = C x in ...(w p q)...)...
-- we want to see that w is strict in its two arguments
wrap_unf | isNewTyCon tycon
= ASSERT( null ex_tyvars && null ex_dict_args && 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 $
mkLams tyvars $ Lam id_arg1 $
mkNewTypeBody tycon result_ty (Var id_arg1)
| not (any isMarkedStrict strict_marks)
= mkCompulsoryUnfolding (Var work_id)
-- The common case. Not only is this efficient,
-- but it also ensures that the wrapper is replaced
-- by the worker even when there are no args.
-- f (:) x
-- becomes
-- f $w: x
-- This is really important in rule matching,
-- (We could match on the wrappers,
-- but that makes it less likely that rules will match
-- when we bring bits of unfoldings together.)
--
-- NB: because of this special case, (map (:) ys) turns into
-- (map $w: ys). The top-level defn for (:) is never used.
-- This is somewhat of a bore, but I'm currently leaving it
-- as is, so that there still is a top level curried (:) for
-- the interpreter to call.
| otherwise
= mkTopUnfolding $ Note InlineMe $
newtype_unf = ASSERT( null ex_tyvars && null ex_dict_args &&
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 $
mkLams tyvars $ Lam id_arg1 $
mkNewTypeBody tycon result_ty (Var id_arg1)
data_unf = mkTopUnfolding $ Note InlineMe $
mkLams all_tyvars $
mkLams ex_dict_args $ mkLams id_args $
foldr mk_case con_app
......@@ -301,9 +303,6 @@ mkDataConWrapId data_con
con_app i rep_ids = mkApps (Var work_id)
(map varToCoreExpr (all_tyvars ++ reverse rep_ids))
(tyvars, _, ex_tyvars, ex_theta, orig_arg_tys, tycon) = dataConSig data_con
all_tyvars = tyvars ++ ex_tyvars
ex_dict_tys = mkPredTys ex_theta
all_arg_tys = ex_dict_tys ++ orig_arg_tys
result_ty = mkTyConApp tycon (mkTyVarTys tyvars)
......
......@@ -300,17 +300,13 @@ pprName name@(Name {n_sort = sort, n_uniq = uniq, n_occ = occ})
pprExternal sty name uniq mod occ
| codeStyle sty = ppr (moduleName mod) <> char '_' <> pprOccName occ
| debugStyle sty = ppr (moduleName mod) <> dot <> pprOccName occ <>
text "{-" <> pprUnique uniq <> text "-}"
| debugStyle sty = ppr (moduleName mod) <> dot <> ppr_debug_occ uniq occ
| unqualStyle sty name = pprOccName occ
| otherwise = ppr (moduleName mod) <> dot <> pprOccName occ
pprInternal sty uniq occ
| codeStyle sty = pprUnique uniq
| debugStyle sty = pprOccName occ <>
text "{-" <> pprUnique uniq <> text "-}"
| debugStyle sty = ppr_debug_occ uniq occ
| otherwise = pprOccName occ -- User style
-- Like Internal, except that we only omit the unique in Iface style
......@@ -320,6 +316,10 @@ pprSystem sty uniq occ
-- If the tidy phase hasn't run, the OccName
-- is unlikely to be informative (like 's'),
-- so print the unique
ppr_debug_occ uniq occ = hsep [pprOccName occ, text "{-",
text (briefOccNameFlavour occ),
pprUnique uniq, text "-}"]
\end{code}
%************************************************************************
......
......@@ -9,7 +9,7 @@
module OccName (
-- The NameSpace type; abstact
NameSpace, tcName, clsName, tcClsName, dataName, varName,
tvName, nameSpaceString,
tvName, srcDataName, nameSpaceString,
-- The OccName type
OccName, -- Abstract, instance of Outputable
......@@ -20,12 +20,14 @@ module OccName (
mkSuperDictSelOcc, mkDFunOcc, mkForeignExportOcc,
mkDictOcc, mkIPOcc, mkWorkerOcc, mkMethodOcc, mkDefaultMethodOcc,
mkDerivedTyConOcc, mkClassTyConOcc, mkClassDataConOcc, mkSpecOcc,
mkGenOcc1, mkGenOcc2, mkLocalOcc,
mkGenOcc1, mkGenOcc2, mkLocalOcc,
mkDataConWrapperOcc, mkDataConWorkerOcc,
isTvOcc, isTcOcc, isDataOcc, isDataSymOcc, isSymOcc, isValOcc,
reportIfUnused,
occNameFS, occNameString, occNameUserString, occNameSpace, occNameFlavour,
occNameFS, occNameString, occNameUserString, occNameSpace,
occNameFlavour, briefOccNameFlavour,
setOccNameSpace,
-- Tidying up
......@@ -89,24 +91,44 @@ pprEncodedFS fs
%************************************************************************
\begin{code}
data NameSpace = VarName -- Variables
| DataName -- Data constructors
data NameSpace = VarName -- Variables, including "source" data constructors
| DataName -- "Real" data constructors
| TvName -- Type variables
| TcClsName -- Type constructors and classes; Haskell has them
-- in the same name space for now.
deriving( Eq, Ord )
{-! derive: Binary !-}
-- Note [Data Constructors]
-- see also: Note [Data Constructor Naming] in DataCon.lhs
--
-- "Source" data constructors are the data constructors mentioned
-- in Haskell source code
--
-- "Real" data constructors are the data constructors of the
-- representation type, which may not be the same as the source
-- type
-- Example:
-- data T = T !(Int,Int)
--
-- The source datacon has type (Int,Int) -> T
-- The real datacon has type Int -> Int -> T
-- GHC chooses a representation based on the strictness etc.
-- Though type constructors and classes are in the same name space now,
-- the NameSpace type is abstract, so we can easily separate them later
tcName = TcClsName -- Type constructors
clsName = TcClsName -- Classes
tcClsName = TcClsName -- Not sure which!
dataName = DataName
tvName = TvName
varName = VarName
dataName = DataName
srcDataName = DataName -- Haskell-source data constructors should be
-- in the Data name space
tvName = TvName
varName = VarName
nameSpaceString :: NameSpace -> String
nameSpaceString DataName = "Data constructor"
......@@ -222,12 +244,22 @@ occNameUserString occ = decode (occNameString occ)
occNameSpace :: OccName -> NameSpace
occNameSpace (OccName sp _) = sp
setOccNameSpace :: OccName -> NameSpace -> OccName
setOccNameSpace (OccName _ occ) sp = OccName sp occ
setOccNameSpace :: NameSpace -> OccName -> OccName
setOccNameSpace sp (OccName _ occ) = OccName sp occ
-- occNameFlavour is used only to generate good error messages
occNameFlavour :: OccName -> String
occNameFlavour (OccName sp _) = nameSpaceString sp
occNameFlavour (OccName DataName _) = "Real data constructor"
occNameFlavour (OccName TvName _) = "Type variable"
occNameFlavour (OccName TcClsName _) = "Type constructor or class"
occNameFlavour (OccName VarName s) = "Variable"
-- briefOccNameFlavour is used in debug-printing of names
briefOccNameFlavour :: OccName -> String
briefOccNameFlavour (OccName DataName _) = "d"
briefOccNameFlavour (OccName VarName _) = "v"
briefOccNameFlavour (OccName TvName _) = "tv"
briefOccNameFlavour (OccName TcClsName _) = "tc"
\end{code}
\begin{code}
......@@ -246,9 +278,11 @@ isValOcc other = False
-- Data constructor operator (starts with ':', or '[]')
-- Pretty inefficient!
isDataSymOcc (OccName DataName s) = isLexConSym (decodeFS s)
isDataSymOcc (OccName VarName s) = isLexConSym (decodeFS s)
isDataSymOcc other = False
isDataOcc (OccName DataName _) = True
isDataOcc (OccName VarName s) = isLexCon (decodeFS s)
isDataOcc other = False
-- Any operator (data constructor or variable)
......@@ -315,11 +349,13 @@ mkDictOcc, mkIPOcc, mkWorkerOcc, mkDefaultMethodOcc,
:: OccName -> OccName
-- These derived variables have a prefix that no Haskell value could have
mkDataConWrapperOcc = mk_simple_deriv varName "$W"
mkWorkerOcc = mk_simple_deriv varName "$w"
mkDefaultMethodOcc = mk_simple_deriv varName "$dm"
mkDerivedTyConOcc = mk_simple_deriv tcName ":" -- The : prefix makes sure it classifies
mkClassTyConOcc = mk_simple_deriv tcName ":T" -- as a tycon/datacon
mkClassDataConOcc = mk_simple_deriv dataName ":D" --
mkClassDataConOcc = mk_simple_deriv dataName ":D" -- We go straight to the "real" data con
-- for datacons from classes
mkDictOcc = mk_simple_deriv varName "$d"
mkIPOcc = mk_simple_deriv varName "$i"
mkSpecOcc = mk_simple_deriv varName "$s"
......@@ -327,6 +363,12 @@ mkForeignExportOcc = mk_simple_deriv varName "$f"
mkGenOcc1 = mk_simple_deriv varName "$gfrom" -- Generics
mkGenOcc2 = mk_simple_deriv varName "$gto" -- Generics
mk_simple_deriv sp px occ = mk_deriv sp px (occNameString occ)
-- Data constructor workers are made by setting the name space
-- of the data constructor OccName (which should be a DataName)
-- to DataName
mkDataConWorkerOcc datacon_occ = setOccNameSpace varName datacon_occ
\end{code}
\begin{code}
......
......@@ -109,10 +109,10 @@ setRdrNameSpace :: RdrName -> NameSpace -> RdrName
-- The original-name case *can* occur when parsing
-- data [] a = [] | a : [a]
-- For the orig-name case we return an unqualified name.
setRdrNameSpace (Unqual occ) ns = Unqual (setOccNameSpace occ ns)
setRdrNameSpace (Qual m occ) ns = Qual m (setOccNameSpace occ ns)
setRdrNameSpace (Orig m occ) ns = Orig m (setOccNameSpace occ ns)
setRdrNameSpace (Exact n) ns = Unqual (setOccNameSpace (nameOccName n) ns)
setRdrNameSpace (Unqual occ) ns = Unqual (setOccNameSpace ns occ)
setRdrNameSpace (Qual m occ) ns = Qual m (setOccNameSpace ns occ)
setRdrNameSpace (Orig m occ) ns = Orig m (setOccNameSpace ns occ)
setRdrNameSpace (Exact n) ns = Unqual (setOccNameSpace ns (nameOccName n))
\end{code}
\begin{code}
......
......@@ -43,7 +43,7 @@ import CostCentre ( currentOrSubsumedCCS, dontCareCCS, CostCentreStack,
currentCCS )
import DataCon ( DataCon, dataConTag,
isUnboxedTupleCon, isNullaryDataCon, dataConWorkId,
dataConWrapId, dataConRepArity
dataConName, dataConRepArity
)
import Id ( Id, idName, idPrimRep )
import Literal ( Literal(..) )
......@@ -138,7 +138,7 @@ at all.
\begin{code}
buildDynCon binder cc con []
= returnFC (stableAmodeIdInfo binder
(CLbl (mkClosureLabel (idName (dataConWrapId con))) PtrRep)
(CLbl (mkClosureLabel (dataConName con)) PtrRep)
(mkConLFInfo con))
\end{code}
......
......@@ -16,16 +16,17 @@ import CoreLint ( endPass )
import CoreSyn
import Type ( Type, applyTy, splitFunTy_maybe,
isUnLiftedType, isUnboxedTupleType, seqType )
import TcType ( TyThing( AnId ) )
import NewDemand ( Demand, isStrictDmd, lazyDmd, StrictSig(..), DmdType(..) )
import Var ( Var, Id, setVarUnique )
import VarSet
import VarEnv
import Id ( mkSysLocal, idType, idNewDemandInfo, idArity,
isFCallId, isGlobalId,
isFCallId, isGlobalId, isImplicitId,
isLocalId, hasNoBinding, idNewStrictness,
isDataConId_maybe, idUnfolding
idUnfolding, isDataConWorkId_maybe
)
import HscTypes ( ModGuts(..), ModGuts, implicitTyThingIds, typeEnvElts )
import HscTypes ( ModGuts(..), ModGuts, typeEnvElts )
import BasicTypes ( TopLevelFlag(..), isTopLevel, isNotTopLevel,