-\begin{code}
-addTyVar, nmbrTyVar :: TyVar -> NmbrM TyVar
-
-addTyVar tv@(TyVar u k maybe_name use) nenv@(NmbrEnv ui ut uu idenv tvenv uvenv)
- = --pprTrace "addTyVar:" (hsep [pprUnique u, pprUnique ut]) $
- case (lookupUFM_Directly tvenv u) of
- Just xx -> -- pprTrace "addTyVar: already in map!" (ppr PprDebug tv) $
- -- (It gets triggered when we do a datatype: first we
- -- "addTyVar" the tyvars for the datatype as a whole;
- -- we will subsequently "addId" the data cons, including
- -- the type for each of them -- each of which includes
- -- _forall_ ...tvs..., which we will addTyVar.
- -- Harmless, if that's all that happens....
- (nenv, xx)
- Nothing ->
- let
- nenv_plus_tv = NmbrEnv ui (incrUnique ut) uu
- idenv
- (addToUFM_Directly tvenv u new_tv)
- uvenv
-
- (nenv2, new_use) = nmbrUsage use nenv_plus_tv
-
- new_tv = TyVar ut k maybe_name new_use
- in
- (nenv2, new_tv)
-
-nmbrTyVar tv@(TyVar u _ _ _) nenv@(NmbrEnv ui ut uu idenv tvenv uvenv)
- = case (lookupUFM_Directly tvenv u) of
- Just xx -> (nenv, xx)
- Nothing ->
- --pprTrace "nmbrTyVar: lookup failed:" (hsep (ppr PprDebug u : [hsep [ppr PprDebug x, ptext SLIT("=>"), ppr PprDebug tv] | (x,tv) <- ufmToList tvenv])) $
- (nenv, tv)
-\end{code}