[mercury-users] define predicate with currying?

Michael Hendricks michael at ndrix.org
Fri Jan 6 02:34:06 AEDT 2012


Thank you Mark and Julien for the informative replies.  The zero-arity
function trick is clever.

--
Michael



On Thu, Jan 5, 2012 at 6:16 AM, Mark Brown <mark at csse.unimelb.edu.au> wrote:
> Hi Michael,
>
> On 05-Jan-2012, Michael Hendricks <michael at ndrix.org> wrote:
>> I have the following simple program:
>>
>>     main(!IO) :-
>>         hello([s("World")], !IO),
>>         hello([s("Mercury")], !IO).
>>
>>     :- pred hello(list(string.poly_type)::in, io::di, io::uo).
>>     hello(Xs,!IO) :- format("Hello, %s!\n",Xs,!IO).
>>
>> Is it possible to define 'hello' by currying 'format'?
>
> No, Mercury doesn't support full currying like Haskell or ML.  The
> underlying reason is that, in Mercury, a constant function returning X
> is not the same value (or type) as X, so curried definitions would be
> ambiguous.
>
> Cheers,
> Mark.
>
> --------------------------------------------------------------------------
> 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
> --------------------------------------------------------------------------

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