[project @ 2005-03-08 17:19:28 by simonmar]
[ghc-hetmet.git] / ghc / compiler / basicTypes / IdInfo.lhs
index 0b5b79a..88d0f3d 100644 (file)
@@ -16,7 +16,6 @@ module IdInfo (
 
        -- Zapping
        zapLamInfo, zapDemandInfo,
-       shortableIdInfo, copyIdInfo,
 
        -- Arity
        ArityInfo,
@@ -87,8 +86,8 @@ import BasicTypes     ( OccInfo(..), isFragileOcc, isDeadOcc, seqOccInfo, isLoopBrea
                          Activation(..)
                        )
 import DataCon         ( DataCon )
+import TyCon           ( TyCon, FieldLabel )
 import ForeignCall     ( ForeignCall )
-import FieldLabel      ( FieldLabel )
 import NewDemand
 import Outputable      
 import Maybe           ( isJust )
@@ -230,7 +229,8 @@ an IdInfo.hi-boot, but no Id.hi-boot, and GlobalIdDetails is imported
 data GlobalIdDetails
   = VanillaGlobal              -- Imported from elsewhere, a default method Id.
 
-  | RecordSelId FieldLabel     -- The Id for a record selector
+  | RecordSelId TyCon FieldLabel  -- The Id for a record selector
+
   | 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
@@ -255,7 +255,7 @@ instance Outputable GlobalIdDetails where
     ppr (ClassOpId _)     = ptext SLIT("[ClassOp]")
     ppr (PrimOpId _)      = ptext SLIT("[PrimOp]")
     ppr (FCallId _)       = ptext SLIT("[ForeignCall]")
-    ppr (RecordSelId _)   = ptext SLIT("[RecSel]")
+    ppr (RecordSelId _ _) = ptext SLIT("[RecSel]")
 \end{code}
 
 
@@ -473,14 +473,14 @@ this to".
 data WorkerInfo = NoWorker
                | HasWorker Id Arity
        -- The Arity is the arity of the *wrapper* at the moment of the
-       -- w/w split. See comments in MkIface.ifaceId, with the 'Worker' code.
+       -- w/w split.  See notes above.
 
 seqWorker :: WorkerInfo -> ()
 seqWorker (HasWorker id a) = id `seq` a `seq` ()
 seqWorker NoWorker        = ()
 
 ppWorkerInfo NoWorker            = empty
-ppWorkerInfo (HasWorker wk_id _) = ptext SLIT("__P") <+> ppr wk_id
+ppWorkerInfo (HasWorker wk_id _) = ptext SLIT("Worker") <+> ppr wk_id
 
 workerExists :: WorkerInfo -> Bool
 workerExists NoWorker        = False
@@ -653,70 +653,3 @@ zapDemandInfo info@(IdInfo {newDemandInfo = dmd})
   | otherwise  = Nothing
 \end{code}
 
-
-copyIdInfo is used when shorting out a top-level binding
-       f_local = BIG
-       f = f_local
-where f is exported.  We are going to swizzle it around to
-       f = BIG
-       f_local = f
-
-BUT (a) we must be careful about messing up rules
-    (b) we must ensure f's IdInfo ends up right
-
-(a) Messing up the rules
-~~~~~~~~~~~~~~~~~~~~
-The example that went bad on me was this one:
-       
-    iterate :: (a -> a) -> a -> [a]
-    iterate = iterateList
-    
-    iterateFB c f x = x `c` iterateFB c f (f x)
-    iterateList f x =  x : iterateList f (f x)
-    
-    {-# RULES
-    "iterate"  forall f x.     iterate f x = build (\c _n -> iterateFB c f x)
-    "iterateFB"                iterateFB (:) = iterateList
-     #-}
-
-This got shorted out to:
-
-    iterateList :: (a -> a) -> a -> [a]
-    iterateList = iterate
-    
-    iterateFB c f x = x `c` iterateFB c f (f x)
-    iterate f x =  x : iterate f (f x)
-    
-    {-# RULES
-    "iterate"  forall f x.     iterate f x = build (\c _n -> iterateFB c f x)
-    "iterateFB"                iterateFB (:) = iterate
-     #-}
-
-And now we get an infinite loop in the rule system 
-       iterate f x -> build (\cn -> iterateFB c f x)
-                   -> iterateFB (:) f x
-                   -> iterate f x
-
-Tiresome solution: don't do shorting out if f has rewrite rules.
-Hence shortableIdInfo.
-
-(b) Keeping the IdInfo right
-~~~~~~~~~~~~~~~~~~~~~~~~
-We want to move strictness/worker info from f_local to f, but keep the rest.
-Hence copyIdInfo.
-
-\begin{code}
-shortableIdInfo :: IdInfo -> Bool
-shortableIdInfo info = isEmptyCoreRules (specInfo info)
-
-copyIdInfo :: IdInfo   -- f_local
-          -> IdInfo    -- f (the exported one)
-          -> IdInfo    -- New info for f
-copyIdInfo f_local f = f { newStrictnessInfo = newStrictnessInfo f_local,
-#ifdef OLD_STRICTNESS
-                          strictnessInfo = strictnessInfo f_local,
-                          cprInfo        = cprInfo        f_local,
-#endif
-                          workerInfo     = workerInfo     f_local
-                         }
-\end{code}