[mercury-users] Mode specific clauses; (f(free)>>f(ground)) vs. (g(free)>>g(ground))

Jörg Roman Rudnick joerg.rudnick at t-online.de
Wed Jan 31 10:21:31 AEDT 2007


  Hi all,

I am afraid the following question (of January 21) got lost inside some 
thread; therefore please allow me to re-post it. Thank you in advance 
for any kind of hint,

    Nick

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Dear experienced ones,

in aim to provide a handy "one arg per config" interface to Tk 
configuration for the mercury_tk interface, I have a question:

First, here is some surrounding code:

:-type data --->
    forename(string);
    surname(string);
    ...
:-inst forenameG ---> forename(ground).
:-inst surnameG ---> surname(ground).
:-inst forenameF ---> forename(free).
:-inst surnameF ---> surname(free).

:-pred isForename(data::(forenameF >> forenameG), io::di, io::uo) is det.
isForename(forename("F"), !IO).
:-pred isSurname(data::(surnameF >> surnameG), io::di, io::uo) is det.
isSurname(surname("S"), !IO).


The attached code sample runs fine as long as there is only a single mode,

    :-pred isName(data, io, io).
    :-mode isName((forenameF >> forenameG), di, uo) is det.
    isName(F::(forenameF >> forenameG), I::di, O::uo) :-
        isForename(F, I, O).

i.e. there are no compiler complaints.

But once I use more modes,

    :-pred isName(data, io, io).
    :-mode isName((forenameF >> forenameG), di, uo) is det.
    :-mode isName((surnameF >> surnameG), di, uo) is det.
    :-pragma promise_pure( isName/3).
    isName(S::(surnameF >> surnameG), I::di, O::uo) :-
        isSurname(S, I, O).
    isName(F::(forenameF >> forenameG), I::di, O::uo) :-
        isForename(F, I, O).

I reveive the following error message:

configMode.m:029: In clause for `isName(((configMode.forenameF) >>
configMode.m:029:   (configMode.forenameG)), di, uo)':
configMode.m:029:   in argument 1 of call to predicate
configMode.m:029:   `configMode.isForename/3':
configMode.m:029:   mode error: variable `F' has instantiatedness `free',
configMode.m:029:   expected instantiatedness was
configMode.m:029:   `bound(configMode.forename(free))'.
configMode.m:026: In clause for `isName(((configMode.surnameF) >>
configMode.m:026:   (configMode.surnameG)), di, uo)':
configMode.m:026:   in argument 1 of call to predicate
configMode.m:026:   `configMode.isSurname/3':
configMode.m:026:   mode error: variable `S' has instantiatedness `free',
configMode.m:026:   expected instantiatedness was
configMode.m:026:   `bound(configMode.surname(free))'.

Is there anybody to explain me this message and - even better ;-) - tell 
me a way to get this problem solved? This would mean I could begin 
finishing mercury_tk, as such an interface to Tk configurations,

    configName(free) >> configName(ground),

would appear quite satisfying to me.


Thank you in advance,

             Nick



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20070131/f1403912/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: configMode.m
Type: text/x-objcsrc
Size: 1146 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/users/attachments/20070131/f1403912/attachment.bin>


More information about the users mailing list