[mercury-users] mode system limitation
Ian MacLarty
maclarty at csse.unimelb.edu.au
Tue Aug 8 16:00:35 AEST 2006
Hello,
I have the following piece of code:
:- type t1
---> a
; b.
:- inst a
---> a.
:- type t2
---> t2(f1 :: t1).
:- inst t2(I)
---> t2(I).
:- pred p(t2::in, t1::out(a)) is det.
p(T2, X) :-
(
T2 ^ f1 = b,
X = a
;
T2 ^ f1 = a,
q(T2, X)
).
:- pred q(t2::in(t2(a)), t1::out(a)) is det.
q(t2(a), a).
When I compile this code I get the following error:
test.m:035: In clause for `p(in, out((test.a)))':
test.m:035: in argument 1 of call to predicate `test.q/2':
test.m:035: mode error: variable `T2' has instantiatedness
test.m:035: `bound(test.t2(ground))',
test.m:035: expected instantiatedness was `bound(test.t2(bound((test.a))))'
If I then change the call to q/2 in the body of p/2 to be:
q(T2 ^ f1 := a, X)
it compiles with no errors.
I have the following questions:
1. Is this a limitation of the current mode system or a bug?
2. If it's a limitation would it be easy to extend the mode system to
handle this case?
3. Is there an alternative modification I can make to the code that
doesn't involve a redundant update of T2 and avoids this limitation
of the mode system?
Ian.
--------------------------------------------------------------------------
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