I know a little Prolog, and frequently use CLP(FD) etc. This paper (written in 2006, apparently) indicates that Mercury now has constraint solving, too. I've found a few mentions of it in the Library Reference Manual. However, I can't find how to use it. For instance:
main(!IO) :-
A >= 2,
A =< 2,
io.write(A, !IO).
gives compiler error
test1.m:011: In clause for `main(di, uo)':
test1.m:011: in argument 1 of call to predicate `int.>='/2:
test1.m:011: mode error: variable `A' has instantiatedness `free',
test1.m:011: expected instantiatedness was `ground'.
but in Prolog, with clpfd,
A #>= 2, A #=< 2.
works fine, giving A = 2 .
(Adding #s to the Mercury code doesn't help.)
How do you do constraint solving in Mercury?