[m-users.] Determinism woes...

emacstheviking objitsu at gmail.com
Fri Jul 5 08:46:29 AEST 2019


Thanks Richard!

That is so obvious when you see it. I am thinking like a Haskell hacker
this evening for sure.
I changed it to "cc_multi" and it compiled ANd did what I expected / wanted.

In my prolog code I have a cut after each match to commit (cc_multi!!!) to
that and no more....OMG (trust me I have to be desparate to even think that
acronym) it really does match !!! I am going to stick that response on a
post-it under my monitor for a whole month!

Currently re-reading section 6 of the manual...sigh...these are the times
when I just know that a formal education might have helped me stumble and
fall a little less.

Thanks again,
Sean.



On Thu, 4 Jul 2019 at 23:40, Richard O'Keefe <raoknz at gmail.com> wrote:

> char_type(')', p_open).
> char_type('(', p_close).
> char_type(_, c_general).
>
> ')' matches two clauses, the first and last.
> '(' matches two clauses, the second and last.
>
> On Fri, 5 Jul 2019 at 10:24, emacstheviking <objitsu at gmail.com> wrote:
>
>> To paraphrase Neo, "I know Prolog".
>>
>> but I don't know Mercury and I am struggling to figure out this
>> error....I am porting some old SWI code and it boils down to the fact that
>> I obvuisly don't truly understand what "det" means! Here is the code both
>> as discrete disjunctive clauses and a single big disjunct:
>>
>> :- pred char_type(char::in, chartype::out) is det.
>>
>> char_type(')', p_open).
>> char_type('(', p_close).
>> char_type(_, c_general).
>>
>> char_type(C, T) :-
>>     (
>>         C = '(', T = p_open
>>     ;   C = ')', T = p_close
>>     ;   C = _,   T = c_general
>>     ).
>>
>> and here is the compiler output:
>>
>> fl1.m:049: In `char_type'(in, out):
>> fl1.m:049:   error: determinism declaration not satisfied.
>> fl1.m:049:   Declared `det', inferred `multi'.
>> fl1.m:056:   Disjunction has multiple clauses with solutions.
>>
>> Now...I understand why (I think) this happens: it's because the final
>> matching disjuny can match more than one character value hence the multiple
>> (multi) classification by the compiler BUT he calling loop seeks merely to
>> convert a character into a character type.
>>
>> Is this "cc_multi" in disguise as if the character is not one of the ones
>> explicitly tested for then I will commit to the first choice as it will be
>> a "general" character i.e. one with no special meaning to my little lexer.
>>
>> Thank you,
>> Sean.
>>
>> _______________________________________________
>> users mailing list
>> users at lists.mercurylang.org
>> https://lists.mercurylang.org/listinfo/users
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20190704/e4992028/attachment.html>


More information about the users mailing list