[mercury-users] Currying to create a higher-order value.
Paul Bone
pbone at csse.unimelb.edu.au
Wed Sep 26 13:53:05 AEST 2007
Recently I submitted a changeset to mercury-reviews for review. Peter
suggested that could use currying to write less code, I've used currying
before to create a higher order term from a predicate name and some
variables such as.
map(transform(Some, Args), ListIn, ListOut)
However I already have a higher order term which I'm trying to curry.
This seems to upset the complier.
list.takewhile(RawThresholdPred(Deep, Threshold), DescendingPSIs, TopPSIs,
_)
I receive the following error.
top_procs.m:108: In clause for function `find_top_procs'/5:
top_procs.m:108: in argument 1 of call to predicate
`list.takewhile'/4:
top_procs.m:108: in unification of argument
top_procs.m:108: and term `RawThresholdPred(Deep, Threshold)':
top_procs.m:108: type error in argument(s) of higher-order term (with
arity
top_procs.m:108: 2).
top_procs.m:108: Functor (RawThresholdPred) has type
`pred((profile.deep),
top_procs.m:108: float, int)',
top_procs.m:108: expected type was `(func(V_32, V_31) = V_33)';
top_procs.m:108: argument 1 (Deep) has type `(profile.deep)',
top_procs.m:108: expected type was `V_32';
top_procs.m:108: argument 2 (Threshold) has type `float',
top_procs.m:108: expected type was `V_31'.
Is this a limiitation of the complier or should I be looking for a
different way to do this. The origital code which I'm trying to improve
is:
ThresholdPred = (pred(PSI::in) is semidet :-
RawThresholdPred(Deep, Threshold, PSI)
),
list.takewhile(RawThresholdPred(Deep, Threshold), DescendingPSIs, TopPSIs,
_),
Thanks.
--------------------------------------------------------------------------
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