[m-users.] Factored out disjunction no longer compiles, generates determinism error.

Sean Charles (emacstheviking) objitsu at gmail.com
Sun May 9 07:30:53 AEST 2021


I think I have reached my limit, Mercury is just too clever for me. I thought I was getting somewhere with it but now I am faced with yet another round of battling determinism errors and left feeling like somebody just shoved my face into a bucket of salty nails.
The fundamental issue is I don’t know what the hell I am doing, I don’t understand at least half the foreign language that the manuals are written in, but I cannot really find anything out there to train myself up. It all feels a bit of an uphill struggle some times.

I decided to factor out the disjuncts into separate predicates starting with the help one, as soon as I did...

repl.m:108: In `parse_cmd'(out, in, out):
repl.m:108:   error: determinism declaration not satisfied.
repl.m:108:   Declared `semidet', inferred `nondet'.
repl.m:111:   Disjunction has multiple clauses with solutions.


:- pred parse_cmd(command::out, list(char)::in, list(char)::out) is semidet.
parse_cmd(Cmd)  —>
    (
        help_cmd(Cmd).   %<=== this is line 111
        %['h','e','l','p'], skip_ws, eol, {Cmd=help}
    ;
        ['l','e','x'], skip_ws, eol, {Cmd=lex}
    ;
        ['a','s','t'], skip_ws, eol, {Cmd=ast}
    ).

:- pred help_cmd(command::out, list(char)::in, list(char)::out) is semidet.

help_cmd(Cmd)  —>
    ['h','e','l','p’],
    skip_ws,
    eol,
    {Cmd=help}.


>>> repl.m:111:   Disjunction has multiple clauses with solutions.

What does this means in English? I know what the disjunction is, it’s the call to help_cmd(), what I don’t get is why it has multiple solutions, I know it is semidet so it might fail or it might succeed with a single solution.
I am going to bed thoroughly disillusioned. I fi didn’t need the money I’d quit software yesterday.
:|

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20210508/20ec2b36/attachment.html>


More information about the users mailing list