[mercury-users] Syntax question: Creating a list of higher order predicates?

obo at ruk.cuni.cz obo at ruk.cuni.cz
Fri Dec 12 00:35:45 AEDT 2003


Hi.

I'd like to create a list of predicates. Something like:

:- type plotter == pred(string, io, io).
:- inst plotter == (pred(in, di, uo) is det).
:- type plotters == list(plotter).
:- inst plotters ????

I'm not really sure how to write the instatiation of plotters -- I wish to
fill the list very simply, still at the compile time, such as
[write_string(String), write_int(15)].

But how do I then declare the mode for the predicate cons:

:- pred cons(list(plotter), indent, io, io).

% :- mode cons(in, in, di, uo) is det.
% This mode decl. is definitely wrong.

cons([], _Indent) --> [].
cons([First|Tail], Indent) -->
  call(First, Indent),
  cons(Tail, Indent).

Thanks for hints, O.

--
Ondrej Bojar (mailto:obo at cuni.cz)
http://www.cuni.cz/~obo


--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list