-mk_edges (TyD (TyData ctxt name _ condecls _ _ _))
- = (uniqueOf name, set_to_bag (get_ctxt ctxt `unionUniqSets` get_cons condecls))
-mk_edges (TyD (TyNew ctxt name _ condecl _ _ _))
- = (uniqueOf name, set_to_bag (get_ctxt ctxt `unionUniqSets` get_cons condecl))
-mk_edges (TyD (TySynonym name _ rhs _))
- = (uniqueOf name, set_to_bag (get_ty rhs))
-mk_edges (ClD (ClassDecl ctxt name _ sigs _ _ _))
- = (uniqueOf name, set_to_bag (get_ctxt ctxt `unionUniqSets` get_sigs sigs))
-
-get_ctxt ctxt
- = unionManyUniqSets (map (set_name.fst) ctxt)
-
-get_cons cons
- = unionManyUniqSets (map get_con cons)
- where
- get_con (ConDecl _ btys _)
- = unionManyUniqSets (map get_bty btys)
- get_con (ConOpDecl bty1 _ bty2 _)
- = unionUniqSets (get_bty bty1) (get_bty bty2)
- get_con (NewConDecl _ ty _)
- = get_ty ty
- get_con (RecConDecl _ nbtys _)
- = unionManyUniqSets (map (get_bty.snd) nbtys)
-
- get_bty (Banged ty) = get_pty ty
- get_bty (Unbanged ty) = get_pty ty
-
-get_ty (MonoTyVar tv)
- = emptyUniqSet
-get_ty (MonoTyApp name tys)
- = (if isRnTyCon name then set_name name else emptyUniqSet)
- `unionUniqSets` get_tys tys
-get_ty (MonoFunTy ty1 ty2)
- = unionUniqSets (get_ty ty1) (get_ty ty2)
-get_ty (MonoListTy ty)
- = get_ty ty -- careful when defining [] (,,) etc as
-get_ty (MonoTupleTy tys) -- [ty] (ty,ty,ty) will not give edges!
- = get_tys tys
-get_ty other = panic "TcTyClsDecls:get_ty"
-
-get_pty (HsForAllTy _ ctxt mty)
- = get_ctxt ctxt `unionUniqSets` get_ty mty
-get_pty other = panic "TcTyClsDecls:get_pty"
-
-get_tys tys
- = unionManyUniqSets (map get_ty tys)
-
-get_sigs sigs
- = unionManyUniqSets (map get_sig sigs)
- where
- get_sig (ClassOpSig _ ty _ _) = get_pty ty
- get_sig other = panic "TcTyClsDecls:get_sig"
-
-set_name name = unitUniqSet (uniqueOf name)
-
-set_to_bag set = listToBag (uniqSetToList set)
-\end{code}