[mercury-users] unification with out arguments

Gordon Tisher gordon at balafon.net
Wed Jun 9 04:02:26 AEST 2010


Hi,

I've come across an interesting situation (rotd 2010-06-06).  The
compiler sometimes doesn't seem to want to unify an "out" argument
with a complex data term given in a predicate call.  The following
small program:

:- module test.

:- interface.
:- pred test is semidet.

:- implementation.
:- import_module char.
:- import_module list.

test :-
	parse(['a'], leaf(_)),                       % why does this work?
	parse(['a', 'b'], node(leaf(_), leaf('b'))). % when this doesn't?
%	parse(['a', 'b'], Tree), Tree = node(leaf(_), leaf('b')). % this works

:- type tree ---> leaf(char) ; node(tree, tree).
:- pred parse(list(char)::in, tree::out) is semidet.

parse([C], leaf(C)).
parse([A,B], node(leaf(A), leaf(B))).


gives the error:

test.m:012: In clause for
test.m:012:   `'__Unify__'((unique(test.node(unique(test.leaf(free)),
test.m:012:   unique(test.leaf(unique('b'))))) >>
test.m:012:   bound(test.node(bound(test.leaf(ground)),
test.m:012:   bound(test.leaf(bound('b')))))), (ground >>
test.m:012:   bound(test.node(bound(test.leaf(ground)),
test.m:012:   bound(test.leaf(bound('b')))))))':
test.m:012:   mode error in unification of `HeadVar__1' and `test.node(V_14,
test.m:012:   V_15)'.
test.m:012:   Variable `HeadVar__1' has instantiatedness
test.m:012:   `unique(test.node(unique(test.leaf(free)),
test.m:012:   unique(test.leaf(unique('b')))))',
test.m:012:   term `test.node(V_14, V_15)' has instantiatedness `test.node(
test.m:012:     free,
test.m:012:     free
test.m:012:   )'.

I'm assuming the "unique" is screwing things up, but why does the
compiler complain about line 12 and not line 11?

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