[mercury-users] insts and modes question

Vladimir Gubarkov xonixx at gmail.com
Thu Apr 15 19:36:16 AEST 2010


Thanks, Raphael for explanation.

Now I've got te point. I just searched through mailing list archives (sorry
for not doing this first) and have found a couple of threads that explains
my question rather explicitly

www.mercury.csse.unimelb.edu.au/mailing-lists/mercury-users/mercury-users.200702/0007.html
<http://www.mercury.csse.unimelb.edu.au/mailing-lists/mercury-users/mercury-users.200702/0007.html>
www.mercury.csse.unimelb.edu.au/mailing-lists/mercury-users/mercury-users.0205/0056.html
<http://www.mercury.csse.unimelb.edu.au/mailing-lists/mercury-users/mercury-users.0205/0056.html>
Btw. To whom this is related.. It seems that search through mailing list
archive is broken is sense that it returns the google search results but all
links point to 404 page (they point to http://www.cs.mu.oz.au/... rather
then to www.mercury.csse.unimelb.edu.au<http://www.mercury.csse.unimelb.edu.au/mailing-lists/mercury-users/mercury-users.200702/0007.html>
).

Sincerely yours,
Vladimir

On Thu, Apr 15, 2010 at 11:17 AM, Raphael Collet
<rco at missioncriticalit.com>wrote:

> Dear Vladimir,
>
> Mercury is not a real logic programming language.  Think of it as a
> functional language syntactically dressed like a logic language.  But the
> fundamentals of logic programming (the logic variables) have been ruled out
> of the language.
>
> I have tried myself to figure out how to use modes to extend the usability
> of the language (in the LP sense), but I gave up.  Modes and insts are too
> limited in practice to do that.  Partially instantiated data structures are
> not supported, and AFAIK there is no plan to support it in the near future.
>
> Regards,
> Raphael
>
>
> Vladimir Gubarkov wrote:
>
>> Hi, dear sirs
>>
>> I'm trying to gain with mercury the next prolog idiom:
>>
>> % code
>> f(A) :-
>>    A = a(B,B).
>>
>> % query
>>  ?- A = a(7,X), f(A).
>> A = a(7, 7),
>> X = 7.
>>
>> I tried to write something like:
>>
>>
>> :- module ref.
>>
>> :- interface.
>>
>> :- import_module io.
>> %:- import_module list.
>>
>> :- pred main(io, io).
>> :- mode main(di, uo) is det.
>>
>> :- implementation.
>>
>>
>> :- type a_type ---> a(int, int).
>>
>> :- inst a_inst ---> a(ground, free).
>> :- mode a_mode == a_inst >> ground.
>>
>> :- pred f(a_type).
>> :- mode f(a_mode) is semidet.
>>
>> f(A) :-
>>    A = a(B,B).
>>
>> main -->
>>     {
>>     (
>>      f(a(7,Q1))
>>     ->
>>      Q = Q1
>>     ;
>>      Q = -1
>>     )
>>     },
>>    io.write_int(Q),
>>    io.nl <http://io.nl>.
>>
>>
>> But mercury (btw, I'm using rotd-2010-04-01-unstable) persistently
>> complains on this like follows:
>>
>> $ mmc -e ref.m
>> ref.m:023: In clause for `f((ref.a_mode))':
>> ref.m:023:   mode error in unification of `A' and `ref.a(B, V_4)'.
>> ref.m:023:   Variable `A' has instantiatedness `bound(ref.a(ground,
>> free))',
>> ref.m:023:   term `ref.a(B, V_4)' has instantiatedness `ref.a(
>> ref.m:023:     free,
>> ref.m:023:     free
>> ref.m:023:   )'.
>> ref.m:028: In clause for `main(di, uo)':
>> ref.m:028:   in argument 1 of call to predicate `ref.f'/1:
>> ref.m:028:   mode error: variable `V_8' has instantiatedness `free',
>> ref.m:028:   expected instantiatedness was `bound(ref.a(ground, free))'.
>> For more information, recompile with `-E'.
>>
>> Yes, I know from documentation, that "The current implementation does not
>> handle partially instantiated data structures yet.". Is this the case?
>> 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.
>> Is there any probability that this feature will be implemented in near
>> future?
>>
>> 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.
>>
>> Sincerely yours,
>> Vladimir.
>>
>
> --------------------------------------------------------------------------
> 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
> --------------------------------------------------------------------------
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20100415/5ddf2a59/attachment.html>


More information about the users mailing list