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

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Mar 7 21:47:37 AEDT 2003


On 07-Mar-2003, Ondrej Bojar <oboj7042 at ss1000.ms.mff.cuni.cz> wrote:
> 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.

The short answer is no.

The long answer is yes, you can have such a predicate,
but you won't be able to use it for much.

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

That is the right solution.

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

There are some examples of the use of mostly_unique modes in
the trailed_update directory of the mercury-extras distribution.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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