[m-users.] Unintelligible compiler message
Volker Wysk
post at volker-wysk.de
Tue Mar 12 01:58:28 AEDT 2019
Am Montag, 11. März 2019, 14:23:06 CET schrieb Zoltan Somogyi:
> On Sun, 10 Mar 2019 23:59:26 +0100, Volker Wysk <post at volker-wysk.de> wrote:
> > Hi
> >
> > I try to compile this little program:
> > :- module test1.
> > :- interface.
> > :- import_module io.
> > :- pred main(io::di, io::uo) is det.
> > :- implementation.
> > :- import_module list, char, string.
> >
> > main(!IO) :-
> >
> > list.map(string.to_char_list, ["abc", "def"], Liste).
> >
> > And get this error message from the compiler:
> >
> > test1.m:010: In clause for `main(di, uo)':
> > test1.m:010: mode error in conjunction. The next 2 error messages
> > indicate test1.m:010: possible causes of this error.
> > test1.m:010: In clause for `main(di, uo)':
> > test1.m:010: in call to predicate `list.map'/3:
> > test1.m:010: mode error: arguments
> > test1.m:010: `TypeCtorInfo_15, TypeInfo_16, V_7, V_8, Liste' have the
> > test1.m:010: following insts:
> > test1.m:010: unique(<type_ctor_info for .string/0>),
> > test1.m:010: bound(
> > test1.m:010: type_info(
> > test1.m:010: bound(
> > test1.m:010: <type_ctor_info for list.list/1>
> > test1.m:010: ),
> > test1.m:010: bound(
> > test1.m:010: <type_ctor_info for .character/0>
> > test1.m:010: )
> > test1.m:010: )
> > test1.m:010: ),
> > test1.m:010: free,
> > test1.m:010: unique,
> > test1.m:010: free
> > test1.m:010: which does not match any of the modes for predicate
> > test1.m:010: `list.map'/3.
> > test1.m:010: In clause for `main(di, uo)':
> > test1.m:010: in argument 1 of call to predicate `list.map'/3:
> > test1.m:010: mode error in unification of `V_7' and higher-order term
> > based test1.m:010: on multi-moded predicate `string.to_char_list'/2.
> > test1.m:010: The modes of the argument variables match more than one of
> > the test1.m:010: called predicate's modes.
> >
> > I half-understand that message. But what I don't understand is, why does
> > it
> > mention five arguments (`TypeCtorInfo_15, TypeInfo_16, V_7, V_8, Liste')
> > to
> > the call of list.map? There are only three!
>
> The two extra arguments come from the fact that the type signature of
> list.map contains two type variables. The caller passes along an extra
> argument for each such type variable, telling the callee the identity of
> the types bound to those type variables.
>
> > I'd like to understand that error message. Could anyone point me at how to
> > find it in the documentation?
>
> It is not in the documentation, because it is the kind of internal detail
> that users shouldn't have to concern themselves with.
>
> I will look into modifying the error message to remove the cause
> of the confusion.
OK. So the three arguments of list.map have the insts free, unique and free.
And there is no mode of list.map for these insts, hence the error. But why is
the first one free? I passed string.to_char_list as the first argument.
Shouldn't it be ground?
Bye
Volker
More information about the users
mailing list