[m-users.] How to specify the mode of a higher order predicate

Dirk Ziegemeyer dirk at ziegemeyer.de
Sat Jul 11 07:56:20 AEST 2015

Dear all,

in the following example mercury complains „… Could not determine the mode of predicate `list.append’/3 by the insts of the higher-order arguments only.“

:- pred test(int::in, list(int)::out) is det.
test(ID, List) :- solutions.aggregate(test2(ID), list.append, [], List).

:- pred test2(int::in, list(int)::out) is nondet.
test2(1, [1, 2, 3]).
test2(1, [4, 5, 6]).

Of course I can wrap list.append inside a new predicate instead of calling it directly like this:

:- mode appendList(in, in, out) is det.
appendList(A, B, C) :- list.append(A, B, C).

I could not find the valid syntax yet for telling mercury the mode of list.append without wrapping it into a new predicate.

Is this possible?



-------------- next part --------------
A non-text attachment was scrubbed...
Name: modeDetermination.err
Type: application/octet-stream
Size: 1762 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/users/attachments/20150710/2c1d2a93/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: modeDetermination.m
Type: application/octet-stream
Size: 589 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/users/attachments/20150710/2c1d2a93/attachment-0001.obj>

More information about the users mailing list