resolveAmbiguity pns inScopeRel t
  =applyTP (full_tdTP (adhocTP idTP rename)) t
       where
         rename  pnt@(PNT pn@(PN (UnQual s) l) ty loc@(N (Just (SrcLoc fileName _  row col))))
          | isTopLevelPNT pnt && ty==Value && elem (pNTtoName pnt) (map pNtoName pns) && not (elem (pNTtoPN pnt) pns) 
          = do let qual@(PlainModule q)= ghead "resolveAmbiguity" (hsQualifier pnt inScopeRel)  
                   pnt'=(PNT (PN (Qual qual s) l) ty loc) 
               update pnt pnt' pnt
         rename x = return x 

-- getQualifier :: HsName.ModuleName->HsModuleP->HsName.ModuleName
resolveAmbiguity pns inScopeRel t
  =applyTP (full_tdTP (adhocTP idTP rename)) t
       where
         rename  pnt@(PNT pn@(PN (UnQual s) l) ty loc@(N (Just (SrcLoc fileName _  row col))))
          | isTopLevelPNT pnt && ty==Value && elem (pNTtoName pnt) (map pNtoName pns) && not (elem (pNTtoPN pnt) pns) 
          = do let qual@(PlainModule q)= ghead "resolveAmbiguity" (hsQualifier pnt inScopeRel)  
                   pnt'=(PNT (PN (Qual qual s) l) ty loc) 
               update pnt pnt' pnt
         rename x = return x 

-- getQualifier :: HsName.ModuleName->HsModuleP->HsName.ModuleName
resolveAmbiguity pns inScopeRel t
  =applyTP (full_tdTP (adhocTP idTP rename)) t
       where
         rename  pnt@(PNT pn@(PN (UnQual s) l) ty loc@(N (Just (SrcLoc fileName _  row col))))
          | isTopLevelPNT pnt && ty==Value && elem (pNTtoName pnt) (map pNtoName pns) && not (elem (pNTtoPN pnt) pns) 
          = do let qual@(PlainModule q)= ghead "resolveAmbiguity" (hsQualifier pnt inScopeRel)  
                   pnt'=(PNT (PN (Qual qual s) l) ty loc) 
               update pnt pnt' pnt
         rename x = return x 

-- getQualifier :: HsName.ModuleName->HsModuleP->HsName.ModuleName