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

Peter Hawkins hawkinsp at cs.stanford.edu
Wed Jan 31 11:04:16 AEDT 2007


Hi...

Short answer: Unfortunately partially instantiated modes don't work
yet. So you can't expect code like this to compile.

I'll have to leave the longer answer to someone else. But I'd like
this to work, too.

Peter

On 1/30/07, Jörg Roman Rudnick <joerg.rudnick at t-online.de> wrote:
>
>
>  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
>
>
>
>
>

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