[m-users.] How to avoid warning about highly ambiguous overloading

Dirk Ziegemeyer dirk at ziegemeyer.de
Tue Jul 19 18:39:13 AEST 2016


Hi,

I create several emtpy maps with the function map.init/0 and mercury warns me about highly ambiguous overloading.

Can I use explicit type qualification to tell Mercury that I mean the function map.init/0 instead of the predicate map.init/1? The section on explicit type qualification in the reference covers the syntax for data terms and it seems that it can't be used for higher order terms.

The error message and the code look like this:

180: In clause for predicate `foo'/7:
180:   warning: highly ambiguous overloading.
180:   The following symbols were overloaded in the following
180:   contexts.
178:   The function symbol `++'/2.
178:   The possible matches are:
178:     function `list.++'/2,
178:     function `string.++'/2.
181:   The function symbol `map.init'/0.
181:   The possible matches are:
181:     predicate `map.init'/1,
181:     function `map.init'/0.
182:   The function symbol `map.init'/0 is also overloaded here.
183:   The function symbol `map.init'/0 is also overloaded here.
182:   The function symbol `set.init'/0.
182:   The possible matches are:
182:     function `set.init'/0,
182:     predicate `set.init'/1.


100: foo(....) :-
180:    read_file(FileName, [], DB1,
181:        map.init, DB2, map.init, DB3, map.init, DB4,
182:        set.init, DB5, map.init, DB6, [], DB7,
183:        map.init, DB8, !IO).

    % Read terms from file with io.read and accumulate each functor in a
    % different database
    %
:- pred read_file(filename_string::in,
    list(a)::in, list(a)::out,      % DB1
    map(b, c)::in, map(b, c)::out,  % DB2
    map(d, e)::in, map(d, e)::out,  % DB3
    map(f, g)::in, map(f, g)::out,  % DB4
    set(h)::in, set(h)::out,        % DB5
    map(i, j)::in, map(i, j)::out,  % DB6
    list(k)::in, list(k)::out,      % DB7
    map(l, m)::in, map(l, m)::out,  % DB8
    io::di, io::uo) is det.

Thank you in advance.

-- 
Dirk Ziegemeyer


More information about the users mailing list