Haskell and Picat style matching

Interestingly there is more in common between Haskell and Picat
style matching. I first thought that Haskell is far away from Picat
style matching, since Haskell diverts into (==)/2 for non-linear

patters. But now I have the feeling that Picat style matching does
the same. Whereas in normal Prolog the normal unification can be
bootstrapped from, on purpose I am writing a rule and not a fact:

=(X,X) :- true.

It seems to me with Picat style matching we can bootstrap term identity:

==(X,X) => true.

True or false? If I call ==(S,T), X will be bound to S, then S will be unified
with T, but no variables of S or T are allowed to be touched. This is only
possible for the identity substitution, so the result will be a S == T test.

So Picat style pattern matching does the same as Haskell, but extends
it to logical variables. Since unlike in Haskell, the terms S and T are
allowed to contain logical variables.

Disclaimer: Need to dig deeper whether this is really true, just a first sketch.

Regarding the difference between Picat and Haskell, perhaps Neng-Fa’s description is of some help: Picat Compared to Other Languages (the section “Picat vs. Haskell”).

But you might already have seen this comparison.

I think that’s the point – the presumption is that a predicate that uses => is deterministic and if you want to make it semi-deterministic, then just add a final catch-all that fails. I find it exteremely helpful for a predicate that I think is deterministic to throw an error when it fails (Haskell will typically generate a compile-time error when it determines that a function doesn’t cover all cases).

1 Like

Haskell is a different language from Prolog, so I fail to see your point. It is possible to write a semi-deterministic identity/2 predicate in Prolog using ‘=>’ (or using ‘:-’, of course), and that’s all I care about. (And, yes, I’ve taken plenty of courses in logic and related computing theory, although it was long enough ago that I’m a bit fuzzy on the details; my point of view is that of a working programmer.)

It’s still early days on the implementation.