[project @ 2003-10-13 14:54:37 by simonpj]
[ghc-hetmet.git] / ghc / compiler / basicTypes / Id.lhs
index 42aa3d1..3d2b4f6 100644 (file)
@@ -30,9 +30,8 @@ module Id (
        isPrimOpId, isPrimOpId_maybe, 
        isFCallId, isFCallId_maybe,
        isDataConWorkId, isDataConWorkId_maybe, 
-       isDataConWrapId, isDataConWrapId_maybe,
-       isBottomingId,
-       hasNoBinding,
+       isBottomingId, idIsFrom,
+       hasNoBinding, 
 
        -- Inline pragma stuff
        idInlinePragma, setInlinePragma, modifyInlinePragma, 
@@ -90,17 +89,20 @@ import Var          ( Id, DictId,
                          globalIdDetails, setGlobalIdDetails
                        )
 import qualified Var   ( mkLocalId, mkGlobalId, mkSpecPragmaId )
-import Type            ( Type, typePrimRep, addFreeTyVars, 
-                          seqType, splitTyConApp_maybe )
+import Type            ( Type, typePrimRep, addFreeTyVars, seqType)
 
 import IdInfo 
 
+#ifdef OLD_STRICTNESS
 import qualified Demand        ( Demand )
+#endif
+import DataCon         ( isUnboxedTupleCon )
 import NewDemand       ( Demand, StrictSig, topDmd, topSig, isBottomingSig )
-import Name            ( Name, OccName,
+import Name            ( Name, OccName, nameIsLocalOrFrom, 
                          mkSystemName, mkSystemNameEncoded, mkInternalName,
                          getOccName, getSrcLoc
                        ) 
+import Module          ( Module )
 import OccName         ( EncodedFS, mkWorkerOcc )
 import PrimRep         ( PrimRep )
 import FieldLabel      ( FieldLabel )
@@ -235,6 +237,7 @@ Meanwhile, it is not discarded as dead code.
 recordSelectorFieldLabel :: Id -> FieldLabel
 recordSelectorFieldLabel id = case globalIdDetails id of
                                 RecordSelId lbl -> lbl
+                                other -> panic "recordSelectorFieldLabel"
 
 isRecordSelector id = case globalIdDetails id of
                        RecordSelId lbl -> True
@@ -264,23 +267,17 @@ isDataConWorkId_maybe id = case globalIdDetails id of
                          DataConWorkId con -> Just con
                          other             -> Nothing
 
-isDataConWrapId_maybe id = case globalIdDetails id of
-                                 DataConWrapId con -> Just con
-                                 other             -> Nothing
-
-isDataConWrapId id = case globalIdDetails id of
-                       DataConWrapId con -> True
-                       other             -> False
-
 -- 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
 -- they aren't any more.  Instead, we inject a binding for 
--- them at the CorePrep stage.
+-- them at the CorePrep stage. 
+-- EXCEPT: unboxed tuples, which definitely have no binding
 hasNoBinding id = case globalIdDetails id of
-                       PrimOpId _  -> True
-                       FCallId _   -> True
-                       other       -> False
+                       PrimOpId _       -> True
+                       FCallId _        -> True
+                       DataConWorkId dc -> isUnboxedTupleCon dc
+                       other            -> False
 
 isImplicitId :: Id -> Bool
        -- isImplicitId tells whether an Id's info is implied by other
@@ -292,7 +289,6 @@ isImplicitId id
         FCallId _       -> True
         PrimOpId _      -> True
        ClassOpId _     -> True
-       GenericOpId _   -> True
         DataConWorkId _ -> True
        DataConWrapId _ -> True
                -- These are are implied by their type or class decl;
@@ -300,6 +296,9 @@ isImplicitId id
                -- The dfun id is not an implicit Id; it must *not* be omitted, because 
                -- it carries version info for the instance decl
        other           -> False
+
+idIsFrom :: Module -> Id -> Bool
+idIsFrom mod id = nameIsLocalOrFrom mod (idName id)
 \end{code}
 
 \begin{code}