Hi, dear sirs<br><br>I'm trying to gain with mercury the next prolog idiom:<br><br>% code<br>f(A) :-<br> A = a(B,B).<br><br>% query<br> ?- A = a(7,X), f(A).<br>A = a(7, 7),<br>X = 7.<br><br>I tried to write something like:<br>
<br><br>:- module ref.<br><br>:- interface.<br><br>:- import_module io.<br>%:- import_module list.<br><br>:- pred main(io, io).<br>:- mode main(di, uo) is det.<br><br>:- implementation.<br><br><br>:- type a_type ---> a(int, int).<br>
<br>:- inst a_inst ---> a(ground, free).<br>:- mode a_mode == a_inst >> ground.<br><br>:- pred f(a_type).<br>:- mode f(a_mode) is semidet.<br><br>f(A) :-<br> A = a(B,B).<br><br>main --><br> {<br> (<br>
f(a(7,Q1))<br> -><br> Q = Q1<br> ;<br> Q = -1<br> )<br> },<br> io.write_int(Q),<br> <a href="http://io.nl">io.nl</a>.<br><br>But mercury (btw, I'm using rotd-2010-04-01-unstable) persistently complains on this like follows:<br>
<br>$ mmc -e ref.m<br>ref.m:023: In clause for `f((ref.a_mode))':<br>ref.m:023: mode error in unification of `A' and `ref.a(B, V_4)'.<br>ref.m:023: Variable `A' has instantiatedness `bound(ref.a(ground, free))',<br>
ref.m:023: term `ref.a(B, V_4)' has instantiatedness `ref.a(<br>ref.m:023: free,<br>ref.m:023: free<br>ref.m:023: )'.<br>ref.m:028: In clause for `main(di, uo)':<br>ref.m:028: in argument 1 of call to predicate `ref.f'/1:<br>
ref.m:028: mode error: variable `V_8' has instantiatedness `free',<br>ref.m:028: expected instantiatedness was `bound(ref.a(ground, free))'.<br>For more information, recompile with `-E'.<br><br>Yes, I know from documentation, that "The current implementation does not handle
partially instantiated data structures yet.". Is this the case?<br>I just wonder then what's the use from those (modes, insts)-magic if all compound insts except for ground and free are hardly useful... Your clarification is greatly appreciated.<br>
Is there any probability that this feature will be implemented in near future? <br><br>Btw, interesting... If I understand correctly strong typed Tubo Prolog supported this feature by means of reference domains, but in last version of Visual Prolog they have dropped this capability.<br>
<br>Sincerely yours,<br>Vladimir.<br>