share exception UNDEF with Table;
authorwenzelm
Sun, 12 Feb 2006 21:34:23 +0100
changeset 19029 8635700e2c9c
parent 19028 6c238953f66c
child 19030 78d43fe9ac65
share exception UNDEF with Table; simplified TableFun.join;
src/Pure/General/graph.ML
--- a/src/Pure/General/graph.ML	Sun Feb 12 21:34:22 2006 +0100
+++ b/src/Pure/General/graph.ML	Sun Feb 12 21:34:23 2006 +0100
@@ -9,9 +9,10 @@
 sig
   type key
   type 'a T
-  exception UNDEF of key
   exception DUP of key
   exception DUPS of key list
+  exception SAME
+  exception UNDEF of key
   val empty: 'a T
   val keys: 'a T -> key list
   val dest: 'a T -> (key * key list) list
@@ -37,7 +38,8 @@
   val add_edge: key * key -> 'a T -> 'a T
   val del_edge: key * key -> 'a T -> 'a T
   val merge: ('a * 'a -> bool) -> 'a T * 'a T -> 'a T                 (*exception DUPS*)
-  val join: (key -> 'a * 'a -> 'a option) -> 'a T * 'a T -> 'a T      (*exception DUPS*)
+  val join: (key -> 'a * 'a -> 'a) (*exception DUP/SAME*) ->
+    'a T * 'a T -> 'a T                                               (*exception DUPS*)
   exception CYCLES of key list list
   val add_edge_acyclic: key * key -> 'a T -> 'a T                     (*exception CYCLES*)
   val add_deps_acyclic: key * key list -> 'a T -> 'a T                (*exception CYCLES*)
@@ -74,9 +76,10 @@
 
 datatype 'a T = Graph of ('a * (key list * key list)) Table.table;
 
-exception UNDEF of key;
 exception DUP = Table.DUP;
 exception DUPS = Table.DUPS;
+exception UNDEF = Table.UNDEF;
+exception SAME = Table.SAME;
 
 val empty = Graph Table.empty;
 fun keys (Graph tab) = Table.keys tab;
@@ -205,9 +208,7 @@
 fun no_edges (i, _) = (i, ([], []));
 
 fun join f (Graph tab1, G2 as Graph tab2) =
-  let
-    fun join_node key ((i1, edges1), (i2, _)) =
-      (Option.map (rpair edges1) o f key) (i1, i2);
+  let fun join_node key ((i1, edges1), (i2, _)) = (f key (i1, i2), edges1)
   in fold add_edge (edges G2) (Graph (Table.join join_node (tab1, Table.map no_edges tab2))) end;
 
 fun gen_merge add eq (Graph tab1, G2 as Graph tab2) =