

On Fri, 11 Oct 2002 Fergus Henderson wrote :
>On 11-Oct-2002, Noel  Pinto <cool4life@rediffmail.com> wrote:
> > :- pred get_next(string::in, bool::out, io__state::di,
> > io__state::uo) is det.
> > get_next(String, More) -->
> > 	io__read_word(get_a), { More = yes},
> > 		if get_a = ok then set_a = get_a else More = no,
> > 	io__read_word(get_b), {More =yes},
> > 		if get_b = ok then set_b = get_b else More = no,
> > 	io__read_word(get_c), {More = yes},
> > 		if get_c = ok then set_c = get_c else More = no.
>
>I have no idea what you are trying to do here.
>What did you expect "io__read_word(get_a)" and "set_a = get_a" to 
>do??

I want to some values to be accepted from the user and update a 
particular field. This is so that I can understand how the Field 
Update and Field Selction works.

>Note that "=" in Mercury is unification, not assignment.
>If "More" has the value "yes", then the goal "More = no"
>will just fail, it won't assign a new value to "More".
>Since this procedure is declared as "det", it is not
>allowed to fail, so this failure would lead to a determinism 
>error.
>
> > Here are the errors:-
> > upd.m:046: Syntax error at token 'if': unexpected token at 
>start
> > of (sub)term.
>
>That's because the "if" statement needs to be enclosed in 
>parentheses.
>
> > upd.m:041: In clause for predicate `upd:main/2':
> > upd.m:041:   in argument 1 of call to predicate 
>`do_while/3':
> > upd.m:041:   error: undefined symbol `getnext/0'.
>
>That's because you mispelt "get_next" as "getnext".
>
> > upd.m:041: In clause for predicate `upd:main/2':
> > upd.m:041:   error: undefined predicate `do_while/3'.
>
>That's because you didn't import the "std_util" standard library 
>module.
>
> > upd.m:043: Error: no clauses for predicate `upd:get_next/4'.
>
>This is a spurious flow-on error caused by the syntax error on 
>line 46.
>It will go away once you fix the syntax error.

I put {} for each if... then... else... and did as you have 
suggested. I get the following errors...
upd.m:046:   constant `get_a' has type `((func (upd:foo)) = 
(upd:a))'.
upd.m:047: In clause for predicate `upd:get_next/4':
upd.m:047:   in argument 1 of call to predicate 
`io:read_word/3':
upd.m:047:   type error: argument has type `((func (upd:foo)) = 
(upd:b))',
upd.m:047:   expected type was 
`(io:result((list:list(character))))'.
upd.m:048: In clause for predicate `upd:get_next/4':
upd.m:048:   type error in unification of argument
upd.m:048:   and constant `ok'.
upd.m:048:   argument has type `((func (upd:foo)) = (upd:b))',
upd.m:048:   constant `ok' has overloaded type
upd.m:048:   { (std_util:maybe_error), (io:result), (io:res) }.
upd.m:048: In clause for predicate `upd:get_next/4':
upd.m:048:   type error in unification of argument
upd.m:048:   and constant `get_b'.
upd.m:048:   argument has type `(func((upd:foo), (upd:b)) = 
(upd:foo))',
upd.m:048:   constant `get_b' has type `((func (upd:foo)) = 
(upd:b))'.
upd.m:049: In clause for predicate `upd:get_next/4':
upd.m:049:   in argument 1 of call to predicate 
`io:read_word/3':
upd.m:049:   type error: argument has type `((func (upd:foo)) = 
(upd:c))',
upd.m:049:   expected type was 
`(io:result((list:list(character))))'.
upd.m:050: In clause for predicate `upd:get_next/4':
upd.m:050:   type error in unification of argument
upd.m:050:   and constant `ok'.
upd.m:050:   argument has type `((func (upd:foo)) = (upd:c))',

These are some of the errors... Could you suggest some 
solutions...

I have also sent some more mails, could you also look at them...

Thanks,

Noel
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users@cs.mu.oz.au
administrative address: owner-mercury-users@cs.mu.oz.au
unsubscribe: Address: mercury-users-request@cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request@cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------

