src/Tools/subtyping.ML
changeset 45935 32f769f94ea4
parent 45429 fd58cbf8cae3
child 46614 165886a4fe64
equal deleted inserted replaced
45934:9321cd2572fe 45935:32f769f94ea4
    29    coes_graph: int Graph.T,
    29    coes_graph: int Graph.T,
    30    tmaps: (term * variance list) Symtab.table};  (*map functions*)
    30    tmaps: (term * variance list) Symtab.table};  (*map functions*)
    31 
    31 
    32 fun make_data (coes, full_graph, coes_graph, tmaps) =
    32 fun make_data (coes, full_graph, coes_graph, tmaps) =
    33   Data {coes = coes, full_graph = full_graph, coes_graph = coes_graph, tmaps = tmaps};
    33   Data {coes = coes, full_graph = full_graph, coes_graph = coes_graph, tmaps = tmaps};
       
    34 
       
    35 fun merge_error_coes (a, b) =
       
    36   error ("Cannot merge coercion tables.\nConflicting declarations for coercions from " ^
       
    37     quote a ^ " to " ^ quote b ^ ".");
       
    38 
       
    39 fun merge_error_tmaps C =
       
    40   error ("Cannot merge coercion map tables.\nConflicting declarations for the constructor " ^
       
    41     quote C ^ ".");
    34 
    42 
    35 structure Data = Generic_Data
    43 structure Data = Generic_Data
    36 (
    44 (
    37   type T = data;
    45   type T = data;
    38   val empty = make_data (Symreltab.empty, Graph.empty, Graph.empty, Symtab.empty);
    46   val empty = make_data (Symreltab.empty, Graph.empty, Graph.empty, Symtab.empty);
    40   fun merge
    48   fun merge
    41     (Data {coes = coes1, full_graph = full_graph1, coes_graph = coes_graph1, tmaps = tmaps1},
    49     (Data {coes = coes1, full_graph = full_graph1, coes_graph = coes_graph1, tmaps = tmaps1},
    42       Data {coes = coes2, full_graph = full_graph2, coes_graph = coes_graph2, tmaps = tmaps2}) =
    50       Data {coes = coes2, full_graph = full_graph2, coes_graph = coes_graph2, tmaps = tmaps2}) =
    43     make_data (Symreltab.merge (eq_pair (op aconv)
    51     make_data (Symreltab.merge (eq_pair (op aconv)
    44         (eq_pair (eq_pair (eq_list (op =)) (eq_list (op =))) (eq_list (op aconv))))
    52         (eq_pair (eq_pair (eq_list (op =)) (eq_list (op =))) (eq_list (op aconv))))
    45         (coes1, coes2),
    53         (coes1, coes2) handle Symreltab.DUP key => merge_error_coes key,
    46       Graph.merge (op =) (full_graph1, full_graph2),
    54       Graph.merge (op =) (full_graph1, full_graph2),
    47       Graph.merge (op =) (coes_graph1, coes_graph2),
    55       Graph.merge (op =) (coes_graph1, coes_graph2),
    48       Symtab.merge (eq_pair (op aconv) (op =)) (tmaps1, tmaps2));
    56       Symtab.merge (eq_pair (op aconv) (op =)) (tmaps1, tmaps2)
       
    57         handle Symtab.DUP key => merge_error_tmaps key);
    49 );
    58 );
    50 
    59 
    51 fun map_data f =
    60 fun map_data f =
    52   Data.map (fn Data {coes, full_graph, coes_graph, tmaps} =>
    61   Data.map (fn Data {coes, full_graph, coes_graph, tmaps} =>
    53     make_data (f (coes, full_graph, coes_graph, tmaps)));
    62     make_data (f (coes, full_graph, coes_graph, tmaps)));