- strict args may be flattened
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.
+ Newtypes have no worker Id
- The "wrapper Id", $wC, whose type is exactly what it looks like
+ 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.
isRecordSelector,
isPrimOpId, isPrimOpId_maybe,
isFCallId, isFCallId_maybe,
- isDataConWorkId, isDataConWorkId_maybe,
+ isDataConWorkId, isDataConWorkId_maybe, idDataCon,
isBottomingId, idIsFrom,
hasNoBinding,
#ifdef OLD_STRICTNESS
import qualified Demand ( Demand )
#endif
-import DataCon ( isUnboxedTupleCon )
+import DataCon ( DataCon, isUnboxedTupleCon )
import NewDemand ( Demand, StrictSig, topDmd, topSig, isBottomingSig )
import Name ( Name, OccName, nameIsLocalOrFrom,
mkSystemVarName, mkSystemVarNameEncoded, mkInternalName,
DataConWorkId con -> Just con
other -> Nothing
+idDataCon :: Id -> DataCon
+-- Get from either the worker or the wrapper to the DataCon
+-- Currently used only in the desugarer
+-- INVARIANT: idDataCon (dataConWrapId d) = d
+-- (Remember, dataConWrapId can return either the wrapper or the worker.)
+idDataCon id = case globalIdDetails id of
+ DataConWorkId con -> con
+ DataConWrapId con -> con
+ other -> pprPanic "idDataCon" (ppr id)
+
+
-- hasNoBinding returns True of an Id which may not have a
-- binding, even though it is defined in this module.
-- Data constructor workers used to be things of this kind, but
-- Data constructor workers are made by setting the name space
-- of the data constructor OccName (which should be a DataName)
--- to DataName
+-- to VarName
mkDataConWorkerOcc datacon_occ = setOccNameSpace varName datacon_occ
\end{code}
import CoreUtils ( exprType, mkIfThenElse, bindNonRec )
import CostCentre ( mkUserCC )
-import Id ( Id, idType, idName, isDataConWorkId_maybe )
+import Id ( Id, idType, idName, idDataCon )
import PrelInfo ( rEC_CON_ERROR_ID, iRREFUT_PAT_ERROR_ID )
import DataCon ( DataCon, dataConWrapId, dataConFieldLabels, dataConInstOrigArgTys )
import DataCon ( isVanillaDataCon )
[] -> mkErrorAppDs rEC_CON_ERROR_ID arg_ty (showSDoc (ppr lbl))
unlabelled_bottom arg_ty = mkErrorAppDs rEC_CON_ERROR_ID arg_ty ""
- labels = dataConFieldLabels (fromJust (isDataConWorkId_maybe data_con_id))
- -- The data_con_id is guaranteed to be the work id of the constructor
+ labels = dataConFieldLabels (idDataCon data_con_id)
+ -- The data_con_id is guaranteed to be the wrapper id of the constructor
in
(if null labels
Fixity -- Renamer adds fixity; bottom until then
(LHsExpr id) -- right operand
- -- We preserve prefix negation and parenthesis for the precedence parser.
- -- They are eventually removed by the type checker.
-
| NegApp (LHsExpr id) -- negated expr
(SyntaxExpr id) -- Name of 'negate'
-- Record construction
| RecordCon (Located id) -- The constructor. After type checking
- -- it's the *worker* Id of the constructor
+ -- it's the dataConWrapId of the constructor
PostTcExpr -- Data con Id applied to type args
(HsRecordBinds id)
import Id ( idType, recordSelectorFieldLabel, isRecordSelector )
import DataCon ( DataCon, dataConFieldLabels, dataConStrictMarks,
- dataConWrapId, dataConWorkId )
+ dataConWrapId )
import Name ( Name )
import TyCon ( TyCon, FieldLabel, tyConTyVars, tyConStupidTheta,
tyConDataCons, tyConFields )
-- Check for missing fields
checkMissingFields data_con rbinds `thenM_`
- returnM (RecordCon (L loc (dataConWorkId data_con)) con_expr rbinds')
+ returnM (RecordCon (L loc (dataConWrapId data_con)) con_expr rbinds')
-- The main complication with RecordUpd is that we need to explicitly
-- handle the *non-updated* fields. Consider:
-> do { checkProcLevel id proc_level
; tc_local_id id th_level }
- -- THis
; other -> failWithTc (ppr other <+> ptext SLIT("used where a value identifer was expected"))
}
where