equal
deleted
inserted
replaced
169 val add_edge = Typ_Graph.add_edge_acyclic; |
169 val add_edge = Typ_Graph.add_edge_acyclic; |
170 fun get_preds G T = Typ_Graph.all_preds G [T]; |
170 fun get_preds G T = Typ_Graph.all_preds G [T]; |
171 fun get_succs G T = Typ_Graph.all_succs G [T]; |
171 fun get_succs G T = Typ_Graph.all_succs G [T]; |
172 fun maybe_new_typnode T G = perhaps (try (Typ_Graph.new_node (T, ()))) G; |
172 fun maybe_new_typnode T G = perhaps (try (Typ_Graph.new_node (T, ()))) G; |
173 fun maybe_new_typnodes Ts G = fold maybe_new_typnode Ts G; |
173 fun maybe_new_typnodes Ts G = fold maybe_new_typnode Ts G; |
174 fun new_imm_preds G Ts = |
174 fun new_imm_preds G Ts = (* FIXME inefficient *) |
175 subtract (op =) Ts (distinct (op =) (maps (Typ_Graph.imm_preds G) Ts)); |
175 subtract (op =) Ts (distinct (op =) (maps (Typ_Graph.immediate_preds G) Ts)); |
176 fun new_imm_succs G Ts = |
176 fun new_imm_succs G Ts = (* FIXME inefficient *) |
177 subtract op= Ts (distinct (op =) (maps (Typ_Graph.imm_succs G) Ts)); |
177 subtract (op =) Ts (distinct (op =) (maps (Typ_Graph.immediate_succs G) Ts)); |
178 |
178 |
179 |
179 |
180 (* Graph shortcuts *) |
180 (* Graph shortcuts *) |
181 |
181 |
182 fun maybe_new_node s G = perhaps (try (Graph.new_node (s, ()))) G |
182 fun maybe_new_node s G = perhaps (try (Graph.new_node (s, ()))) G |
404 end; |
404 end; |
405 |
405 |
406 (*styps stands either for supertypes or for subtypes of a type T |
406 (*styps stands either for supertypes or for subtypes of a type T |
407 in terms of the subtype-relation (excluding T itself)*) |
407 in terms of the subtype-relation (excluding T itself)*) |
408 fun styps super T = |
408 fun styps super T = |
409 (if super then Graph.imm_succs else Graph.imm_preds) coes_graph T |
409 (if super then Graph.immediate_succs else Graph.immediate_preds) coes_graph T |
410 handle Graph.UNDEF _ => []; |
410 handle Graph.UNDEF _ => []; |
411 |
411 |
412 fun minmax sup (T :: Ts) = |
412 fun minmax sup (T :: Ts) = |
413 let |
413 let |
414 fun adjust T U = if sup then (T, U) else (U, T); |
414 fun adjust T U = if sup then (T, U) else (U, T); |