Store a SrcSpan instead of a SrcLoc inside a Name
[ghc-hetmet.git] / compiler / basicTypes / Id.lhs
index 549a58b..e2e991a 100644 (file)
@@ -25,7 +25,7 @@ module Id (
        zapLamIdInfo, zapDemandIdInfo, zapFragileIdInfo,
 
        -- Predicates
-       isImplicitId, isDeadBinder, isDictId,
+       isImplicitId, isDeadBinder, isDictId, isStrictId,
        isExportedId, isLocalId, isGlobalId,
        isRecordSelector, isNaughtyRecordSelector,
        isClassOpId_maybe,
@@ -154,7 +154,7 @@ mkSysLocal fs uniq ty = mkLocalId (mkSystemVarName uniq fs) ty
 
 
 -- UserLocal: an Id with a name the user might recognize...
-mkUserLocal :: OccName -> Unique -> Type -> SrcLoc -> Id
+mkUserLocal :: OccName -> Unique -> Type -> SrcSpan -> Id
 mkVanillaGlobal :: Name -> Type -> IdInfo -> Id
 
 mkUserLocal occ uniq ty loc = mkLocalId (mkInternalName    uniq occ loc) ty
@@ -175,7 +175,7 @@ mkWorkerId :: Unique -> Id -> Type -> Id
 mkWorkerId uniq unwrkr ty
   = mkLocalId wkr_name ty
   where
-    wkr_name = mkInternalName uniq (mkWorkerOcc (getOccName unwrkr)) (getSrcLoc unwrkr)
+    wkr_name = mkInternalName uniq (mkWorkerOcc (getOccName unwrkr)) (getSrcSpan unwrkr)
 
 -- "Template locals" typically used in unfoldings
 mkTemplateLocals :: [Type] -> [Id]
@@ -214,9 +214,10 @@ idPrimRep id = typePrimRep (idType id)
 
 \begin{code}
 recordSelectorFieldLabel :: Id -> (TyCon, FieldLabel)
-recordSelectorFieldLabel id = case globalIdDetails id of
-                                RecordSelId tycon lbl _ -> (tycon,lbl)
-                                other -> panic "recordSelectorFieldLabel"
+recordSelectorFieldLabel id
+  = case globalIdDetails id of
+       RecordSelId { sel_tycon = tycon, sel_label = lbl } -> (tycon,lbl)
+       other -> panic "recordSelectorFieldLabel"
 
 isRecordSelector id = case globalIdDetails id of
                        RecordSelId {}  -> True
@@ -368,6 +369,20 @@ setIdNewStrictness id sig = modifyIdInfo (`setNewStrictnessInfo` Just sig) id
 
 zapIdNewStrictness :: Id -> Id
 zapIdNewStrictness id = modifyIdInfo (`setNewStrictnessInfo` Nothing) id
+\end{code}
+
+This predicate says whether the id has a strict demand placed on it or
+has a type such that it can always be evaluated strictly (e.g., an
+unlifted type, but see the comment for isStrictType).  We need to
+check separately whether <id> has a so-called "strict type" because if
+the demand for <id> hasn't been computed yet but <id> has a strict
+type, we still want (isStrictId <id>) to be True.
+\begin{code}
+isStrictId :: Id -> Bool
+isStrictId id
+  = ASSERT2( isId id, text "isStrictId: not an id: " <+> ppr id )
+           (isStrictDmd (idNewDemandInfo id)) || 
+           (isStrictType (idType id))
 
        ---------------------------------
        -- WORKER ID