[mercury-users] higher order preds and type variables
Barney Fisher
barney.fisher at googlemail.com
Mon Nov 12 23:27:56 AEDT 2007
Hi,
I have a program where a polymorphic pred is passed as input to
another predicate and then called with values of a specific type, but
I am getting compile errors which I don't understand. The following
program illustrates what i'm trying to do.
-----------------------------------------
:- module ho.
:- interface.
:- import_module io.
:- pred main(io::di,io::uo) is det.
:- implementation.
:- type aa ---> aa.
:- pred p1(A::in) is det.
p1(_).
:- pred p2(pred(A)::in(pred(in) is det)) is det.
p2(P) :- P(aa).
main(!IO) :- p2(p1).
---------------------------------------------
When I try compiling this I get
ho.m:017: In clause for predicate `p2'/1:
ho.m:017: in argument 2 (i.e. argument 1 of the called predicate) of
ho.m:017: higher-order predicate call:
ho.m:017: type error: argument has type `(ho.aa)',
ho.m:017: expected type was `(some [A] A)'.
Could someone please explain to me the problem (and a solution if possible!)?
Thanks
--
Barney
--------------------------------------------------------------------------
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