(F)SLIT -> (f)sLit in Var
[ghc-hetmet.git] / compiler / basicTypes / Var.lhs
index 2b7b1d6..d9cedf0 100644 (file)
@@ -40,9 +40,7 @@ import {-# SOURCE #-} TypeRep( Type, Kind )
 import {-# SOURCE #-}  TcType( TcTyVarDetails, pprTcTyVarDetails )
 import {-# SOURCE #-}  IdInfo( GlobalIdDetails, notGlobalId, 
                                 IdInfo, seqIdInfo )
-#ifdef DEBUG
 import {-# SOURCE #-}  TypeRep( isCoercionKind )
-#endif
 
 import Name hiding (varName)
 import Unique
@@ -129,9 +127,9 @@ instance Outputable Var where
   ppr var = ppr (varName var) <+> ifPprDebug (brackets extra)
        where
          extra = case var of
-                       GlobalId {} -> ptext SLIT("gid")
-                       LocalId  {} -> ptext SLIT("lid")
-                       TyVar    {} -> ptext SLIT("tv")
+                       GlobalId {} -> ptext (sLit "gid")
+                       LocalId  {} -> ptext (sLit "lid")
+                       TyVar    {} -> ptext (sLit "tv")
                        TcTyVar {tcTyVarDetails = details} -> pprTcTyVarDetails details
 
 instance Show Var where
@@ -161,12 +159,12 @@ varUnique var = mkUniqueGrimily (iBox (realUnique var))
 
 setVarUnique :: Var -> Unique -> Var
 setVarUnique var uniq 
-  = var { realUnique = getKey# uniq, 
+  = var { realUnique = getKeyFastInt uniq, 
          varName = setNameUnique (varName var) uniq }
 
 setVarName :: Var -> Name -> Var
 setVarName var new_name
-  = var { realUnique = getKey# (getUnique new_name), 
+  = var { realUnique = getKeyFastInt (getUnique new_name), 
          varName = new_name }
 \end{code}
 
@@ -180,10 +178,16 @@ setVarName var new_name
 \begin{code}
 type TyVar = Var
 
+tyVarName :: TyVar -> Name
 tyVarName = varName
+
+tyVarKind :: TyVar -> Kind
 tyVarKind = varType
 
+setTyVarUnique :: TyVar -> Unique -> TyVar
 setTyVarUnique = setVarUnique
+
+setTyVarName :: TyVar -> Name -> TyVar
 setTyVarName   = setVarName
 
 setTyVarKind :: TyVar -> Kind -> TyVar
@@ -194,7 +198,7 @@ setTyVarKind tv k = tv {varType = k}
 mkTyVar :: Name -> Kind -> TyVar
 mkTyVar name kind = ASSERT( not (isCoercionKind kind ) )
                    TyVar { varName    = name
-                         , realUnique = getKey# (nameUnique name)
+                         , realUnique = getKeyFastInt (nameUnique name)
                          , varType  = kind
                           , isCoercionVar    = False
                        }
@@ -204,7 +208,7 @@ mkTcTyVar name kind details
   = -- TOM: no longer valid assertion? 
     -- ASSERT( not (isCoercionKind kind) )
     TcTyVar {  varName    = name,
-               realUnique = getKey# (nameUnique name),
+               realUnique = getKeyFastInt (nameUnique name),
                varType  = kind,
                tcTyVarDetails = details
        }
@@ -219,17 +223,23 @@ mkTcTyVar name kind details
 \begin{code}
 type CoVar = Var       -- A coercion variable is simply a type 
                        -- variable of kind (ty1 :=: ty2)
+
+coVarName :: CoVar -> Name
 coVarName = varName
 
+setCoVarUnique :: CoVar -> Unique -> CoVar
 setCoVarUnique = setVarUnique
+
+setCoVarName :: CoVar -> Name -> CoVar
 setCoVarName   = setVarName
 
 mkCoVar :: Name -> Kind -> CoVar
 mkCoVar name kind = ASSERT( isCoercionKind kind )
-                   TyVar { varName    = name
-                         , realUnique = getKey# (nameUnique name)
-                         , varType  = kind
-                          , isCoercionVar    = True
+                   TyVar { varName       = name
+                         , realUnique    = getKeyFastInt (nameUnique name)
+                         , varType       = kind        
+                               -- varType is always PredTy (EqPred t1 t2)
+                          , isCoercionVar = True
                        }
 
 mkWildCoVar :: Kind -> TyVar
@@ -237,7 +247,7 @@ mkWildCoVar :: Kind -> TyVar
 -- so its unique doesn't matter
 mkWildCoVar kind 
   = ASSERT( isCoercionKind kind )
-    TyVar { varName = mkSysTvName wild_uniq FSLIT("co_wild"),
+    TyVar { varName = mkSysTvName wild_uniq (fsLit "co_wild"),
             realUnique = _ILIT(1),
             varType = kind,
             isCoercionVar = True }
@@ -259,6 +269,10 @@ type DictId = Id
 \end{code}
 
 \begin{code}
+idName   :: Id -> Name
+idUnique :: Id -> Unique
+idType   :: Id -> Kind
+
 idName    = varName
 idUnique  = varUnique
 idType    = varType
@@ -324,7 +338,7 @@ maybeModifyIdInfo Nothing     id = id
 mkGlobalId :: GlobalIdDetails -> Name -> Type -> IdInfo -> Id
 mkGlobalId details name ty info 
   = GlobalId { varName    = name, 
-               realUnique = getKey# (nameUnique name),         -- Cache the unique
+               realUnique = getKeyFastInt (nameUnique name),   -- Cache the unique
                varType     = ty,       
                gblDetails = details,
                idInfo_    = info }
@@ -332,7 +346,7 @@ mkGlobalId details name ty info
 mk_local_id :: Name -> Type -> LocalIdDetails -> IdInfo -> Id
 mk_local_id name ty details info
   = LocalId {  varName    = name, 
-               realUnique = getKey# (nameUnique name),         -- Cache the unique
+               realUnique = getKeyFastInt (nameUnique name),   -- Cache the unique
                varType     = ty,       
                lclDetails = details,
                idInfo_    = info }
@@ -349,29 +363,30 @@ isTyVar, isTcTyVar            :: Var -> Bool
 isId, isLocalVar, isLocalId :: Var -> Bool
 isGlobalId, isExportedId    :: Var -> Bool
 mustHaveLocalBinding       :: Var -> Bool
+isCoVar                     :: Var -> Bool
 
 isTyVar (TyVar {})   = True
 isTyVar (TcTyVar {}) = True
-isTyVar other       = False
+isTyVar _            = False
 
 isTcTyVar (TcTyVar {}) = True
-isTcTyVar other               = False
+isTcTyVar _            = False
 
 isId (LocalId {})  = True
 isId (GlobalId {}) = True
-isId other        = False
+isId _             = False
 
 isLocalId (LocalId {}) = True
-isLocalId other               = False
+isLocalId _            = False
 
 isCoVar (v@(TyVar {})) = isCoercionVar v
-isCoVar other          = False
+isCoVar _              = False
 
 -- isLocalVar returns True for type variables as well as local Ids
 -- These are the variables that we need to pay attention to when finding free
 -- variables, or doing dependency analysis.
 isLocalVar (GlobalId {}) = False 
-isLocalVar other        = True
+isLocalVar _             = True
 
 -- mustHaveLocalBinding returns True of Ids and TyVars
 -- that must have a binding in this module.  The converse
@@ -381,21 +396,21 @@ isLocalVar other   = True
 mustHaveLocalBinding var = isLocalVar var
 
 isGlobalId (GlobalId {}) = True
-isGlobalId other        = False
+isGlobalId _             = False
 
 -- isExportedId means "don't throw this away"
 isExportedId (GlobalId {}) = True
 isExportedId (LocalId {lclDetails = details}) 
   = case details of
        Exported   -> True
-       other      -> False
-isExportedId other = False
+       _          -> False
+isExportedId _ = False
 \end{code}
 
 \begin{code}
 globalIdDetails :: Var -> GlobalIdDetails
 -- Works OK on local Ids too, returning notGlobalId
 globalIdDetails (GlobalId {gblDetails = details}) = details
-globalIdDetails other                            = notGlobalId
+globalIdDetails _                                 = notGlobalId
 \end{code}