[mercury-users] type error with existentially typed data structure

Peter Ross peter.ross at miscrit.be
Fri Sep 7 19:30:29 AEST 2001


In the following code (the full code for the module is in my original
post)

:- pred bind_env(arc_place_transition::in,
                environment::out, petri::in, petri::out) is nondet.

bind_env(ArcPlaceTransition, Env, Petri0, Petri) :-
        ArcPlaceTransition = arc_place_transition(BindEnv, From),
        Place = get_place(Petri0, From),
        set__member(Token, Place ^ tokens),
        Env = BindEnv(Token),
        Petri = Petri0.

I tried to get rid of the following error

petri.m:128: In clause for `bind_env(in, out, in, out)':
petri.m:128:   in argument 1 (i.e. the function term) of higher-order function call:
petri.m:128:   mode error: variable `BindEnv' has instantiatedness `ground',
petri.m:128:   expecting higher-order func inst (of arity 1).
For more information, try recompiling with `-E'.

by changing the predicate definition to 

:- inst bind == (func(ground >> ground) = (free >> ground) is det).
:- inst arc_place_transition == bound(
        arc_place_transition(ground, bind, ground)).

:- pred bind_env(arc_place_transition::in(arc_place_transition),
                environment::out, petri::in, petri::out) is nondet.

Note that you need to add an extra argument for the TypeInfo storing the
type of the existentially typed argument, which is pretty ugly.

Anyway I then get the following error.

petri.m:121: In `bind_env(in((petri:arc_place_transition)), out, in, out)':
petri.m:121:   warning: determinism declaration could be tighter.
petri.m:121:   Declared `nondet', inferred `failure'.

This looks like a bug to me.

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