[mercury-users] Documentation error? Higher-order-inst example needs extra parentheses.
Julian Fondren
ayrnieu at gmail.com
Sat Feb 10 23:08:10 AEDT 2007
>From the Mercury Language Reference Manual, section 8.3,
Higher Order Modes:
If you want to define a predicate which returns a higher-order
predicate term, you would use a mode such as `free >> pred(...) is ...',
or `out(pred(...) is ... )'. For example:
:- pred foo(pred(int)).
:- mode foo(free >> pred(out) is det) is det.
foo(sum([1,2,3])).
However, the trailing analogous code example emits the following
inst errors unless I put parentheses around the higher-order inst,
to say (pred(out is det)).
inst_fail.m:017: In mode declaration for predicate `inst_fail.foo'/1:
inst_fail.m:017: error: undefined inst `in'/0.
inst_fail.m:017: In mode declaration for predicate `inst_fail.foo'/1:
inst_fail.m:017: error: undefined inst `func'/1.
inst_fail.m:017: In mode declaration for predicate `inst_fail.foo'/1:
inst_fail.m:017: error: undefined inst `>>'/2.
inst_fail.m:017: In mode declaration for predicate `inst_fail.foo'/1:
inst_fail.m:017: error: undefined inst `out'/0.
inst_fail.m:017: In mode declaration for predicate `inst_fail.foo'/1:
inst_fail.m:017: error: undefined inst `='/2.
inst_fail.m:017: In mode declaration for predicate `inst_fail.foo'/1:
inst_fail.m:017: error: undefined inst `det'/0.
inst_fail.m:017: In mode declaration for predicate `inst_fail.foo'/1:
inst_fail.m:017: error: undefined mode `is'/2.
:- module inst_fail.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module int, list, string.
main(!IO) :-
foo(F),
io.format("sum([1,2,3]) = %d\n", [i(F([1,2,3]))], !IO).
:- func sum(list(int)) = int.
sum([]) = 0.
sum([H|T]) = H + sum(T).
:- pred foo(func(list(int)) = int).
:- mode foo(free >> func(in) = out is det) is det.
foo(sum).
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to: mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions: mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the users
mailing list