Re: Some syntax sugar for logic programming

From: Michael Hanus <>
Date: Fri, 31 Oct 2014 15:48:56 +0100

On 10/31/2014 06:16 AM, wrote:
> Actually, an infix disjunction is what interests me more, less is where it resides. Is there such in Curry?

I am not sure what you mean, but there is the prelude operator "?"
which denotes a choice and, thus, on the constraint level,
a disjunction.

>> The only tricky issue is to retain unification, if possible.
>> For instance, in the initial expression
>> x==[1,2] where x free
>> one would like to bind x to the list [1,2] instead of instantiating
>> x to all integer lists and produce False for all lists except [1,2].
>> However, this could be easily expressed by
>> solve (x==[1,2]) where x free
> The idea is cool, but isn’t it a case where some people will forget to use solve() resulting in performance degradation of their programs?

The point is that "solve" is only necessary for top-level expressions
where a bigger context is missing.
If "==" is used on conditions, it can be transformed into unification.
If "==" is used in an if-then-else, it cannot be transformed but
this is intended (for the sake of completeness) since one is interested
in "True" as well as "False" results.

> No, i’ve used this in a pure logic context. Isn’t it possible to extend unification to support such syntax, or i miss something?

Unification has no specific syntax (in contrast to pattern matching),
i.e., "=:=" is an infix operator as any other infix operator.
For instance, you might redefine it by

x `unify` y = x =:= y

Hence, it seems difficult to provide a specific syntax for it.

Best regards,


curry mailing list
Received on Fr Okt 31 2014 - 16:17:38 CET

This archive was generated by hypermail 2.3.0 : Do Jun 20 2024 - 07:15:13 CEST