[mercury-users] Type error in higher-order predicate and existential type

Paul Bone pbone at csse.unimelb.edu.au
Tue Nov 6 10:52:07 AEDT 2007


On Tue, Nov 06, 2007 at 09:24:21AM +1100, Peter Ross wrote:
> On 11/6/07, François Degrave <fde at info.fundp.ac.be> wrote:
> > Dear all,
> >
> >
> > Using a higher-order predicate, I get an type error and I don't
> > understand where it comes from. Here is a much simplified version of the
> > predicate I wrote :
> >
> > :- pred higher_order_pred(pred(T,T),T).
> > :- mode higher_order_pred(in(pred(in, out) is semidet),out) is semidet.
> > higher_order_pred(HOPred,Result) :- call(HOPred,5,Result).
> >
> For the line
> 
> call(HOPred, 5, Result)
> 
> the first argument to the higher-order pred is an int, but you said in
> the type declaration that it can be any T thus the error.
> 
> :- pred higher_order_pred(pred(int,int),int).
> 
> fixes the error.

Alternativly

:- pred higher_order_pred(pred(int, T), T).

This is more general.  And the type of T will be defined by how
higher_order_pred is used.


--------------------------------------------------------------------------
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