[Haskell-cafe] Interesting feature

Henning Thielemann lemming at henning-thielemann.de
Mon Jul 7 06:30:34 EDT 2008

On Mon, 7 Jul 2008, fero wrote:

> Hi I have read in one tutorial (I can't find it again, but it was probably
> either one on ibm, gentle introduction or yaht), that it is possible to
> define relationships between free variables and the same program can be used
> to calculate either first variable when second is set or second when first
> is set. I have understood this as if I set first free variable, run program
> and write name of second variable and I get result, and vice versa. I don't
> know if I understood it well. It looks really interesting but I can't figure
> out how to do it. Is this really possible? (I doubt.) If yes show example
> please.

Are you talking about logic programming and PROLOG?
$ pl  # swi-prolog

?- plus(X,2,3).

X = 1 ;

?- plus(1,X,3).

X = 2 ;

?- plus(1,2,X).

X = 3 ;


  Actually the type system of Haskell is also logic programming. I have 
implemented a simple kind of logic programming using lazy peano numbers:

More information about the Haskell-Cafe mailing list