[mercury-users] currying does not work with higher order predicates ?
Tyson Dowd
trd at cs.mu.OZ.AU
Tue Jul 24 20:42:32 AEST 2001
Mercury doesn't really allow implicit currying everywhere, you
can't just add arguments to an existing closure, but instead you
have to write an explicit lambda expression:
e.g. (func(X) = ....) or (pred(X::in) :- ....)
So try:
io__write_list(XForms, ",\n",
(pred(A::in, di, uo) ---> WriteXForm("di", "uo", A) )),
io__write_list(XForms, ",\n",
(pred(A::in, di, uo) ---> WriteXForm("in", "out", A) )),
On 24-Jul-2001, Holger Krug <hkrug at rationalizer.com> wrote:
> I currently make some changes to moose to "allow the parsing state to
> be unique (so that it can contain the io:state, just for example)."
>
> To this purpose it tried to modify existing moose code to something like:
>
> { WriteXForm = (pred(InMode::in, OutMode::in, XForm::in, di, uo)
> is det -->
> { XForm = xform(NT, MethodName) },
> { lookup(Decls, NT, RuleDecl) },
> { RuleDecl = rule(_NT, Types, VarSet, _Context) },
> io__write_strings(["\tpred ", MethodName, "("]),
> io__write_list(Types, ", ", term_io__write_term(VarSet)),
> ( { Types \= [] } -> io__write_string(", ") ; [] ),
> io__write_string("T, T),\n"),
>
> io__write_strings(["\tmode ", MethodName, "("]),
> io__write_list(Types, ", ", WriteIn),
> ( { Types \= [] } -> io__write_string(", ") ; [] ),
> io__write_string(InMode),
> io__write_string(", "),
> io__write_string(OutMode),
> io__write_string(") is det")
> )
> },
> ( { UniqueModes = yes } ->
> #279 io__write_list(XForms, ",\n", WriteXForm("di", "uo"))
> ;
> #281 io__write_list(XForms, ",\n", WriteXForm("in", "out"))
> ),
>
> #xxx are the line numbers.
>
> I get the following error messages:
>
> moose.m:279: In clause for predicate `moose:write_action_type_class/6':
> moose.m:279: in argument 3 of call to predicate `io:write_list/5':
> moose.m:279: in unification of argument
> moose.m:279: and term `''(WriteXForm, V_46, V_47)':
> moose.m:279: type error in argument(s) of functor `/3'.
> moose.m:279: Argument 1 (WriteXForm) has type `pred(string, string, (grammar:xform), (io:state), (io:state))',
> moose.m:279: expected type was `(func(V_30, V_29) = V_31)'.
> moose.m:281: In clause for predicate `moose:write_action_type_class/6':
> moose.m:281: in argument 3 of call to predicate `io:write_list/5':
> moose.m:281: in unification of argument
> moose.m:281: and term `''(WriteXForm, V_50, V_51)':
> moose.m:281: type error in argument(s) of functor `/3'.
> moose.m:281: Argument 1 (WriteXForm) has type `pred(string, string, (grammar:xform), (io:state), (io:state))',
> moose.m:281: expected type was `(func(V_31, V_30) = V_32)'.
>
> It seems as if currying is not allowed for higher order predicates.
> Is this assumption correct or did I make some other kind of error ?
>
> --
> Holger Krug
> hkrug at rationalizer.com
> --------------------------------------------------------------------------
> 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
> --------------------------------------------------------------------------
--------------------------------------------------------------------------
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