[mercury-users] Compiled a library, linked to a program... but no calls are performed

Ondrej Bojar oboj7042 at ss1000.ms.mff.cuni.cz
Fri Mar 7 20:38:18 AEDT 2003


On Fri, 7 Mar 2003, Fergus Henderson wrote:
> Even so, since you're in I/O code, the goal inside `{...}' as a whole
> must be det; otherwise the Mercury compiler would report a determinism
> error for main/2.  So if `--no-fully-strict' was specified, the Mercury
> compiler could optimize away the whole goal inside `{...}', even if it
> contained semidet subgoals.

Yes! That was probably the problem. I added the IO threads so that I do
not lie to the compiler any more, and it suddenly works!

BTW, is it possible to have a predicate with the following mode?

:- pred foo(OutType::out, io::di, io::uo) is semidet.

I didn't find any such example neither in library, nor in extras. I guess,
this introduces the necessity of mostly_unique mode, but I really
didn't understand the description in the Language Reference enough.

So I solved it by introducing

:- type foo_output(OutType) --> failed; ok(OutType).
% well, this is already defined in module io, I know.

and changed the predicate to

:- pred foo(foo_output(OutType)::out, io::di, io::uo) is det.

Was it neccessary?

In fact: I understand perfectly, what unique and mostly_unique modes are
meant for, but I still do not understand enough to write a correct (i.e.
compilable) code with them; except for standard IO threadding. Are there
commented examples somewhere? Ralph Becket's book?

Thanks, Andrew.




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



More information about the users mailing list