[mercury-users] Newbie Q on type parameters

Ralph Becket rafe at csse.unimelb.edu.au
Tue Aug 28 13:56:29 AEST 2007


Tom Davies, Tuesday, 28 August 2007:
> I want to use types to reduce repetition when declaring the predicate  
> parameters -- is this a sensible approach:

Yes, indeed.

> :- type succ_pred(T) == pred(T, T).
> :- inst succ_pred == (pred(in,out) is nondet).
> :- mode succ_pred_in == succ_pred >> succ_pred.

You can simplify that mode to

:- mode succ_pred_in == in(succ_pred).

> :- pred solve(succ_pred(T)::succ_pred_in, ...
> 
> Now my predicate of type succ_pred(node) is declared:
> 
> :- type node ---> a; b; c; d; e; f; g.
> :- pred s `with_type` succ_pred(node) `with_inst` succ_pred.
> s(a,b).
> ...
> 
> Is that the best way to do this?

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