[mercury-users] Re: coloured petri nets
Peter Ross
peter.ross at miscrit.be
Thu Sep 6 21:05:42 AEST 2001
On Thu, Sep 06, 2001 at 03:26:12AM -0700, Ralph Becket wrote:
> >
> > main.m:033: In clause for predicate `main:main/2':
> > main.m:033: in argument 2 of call to predicate `f/3':
> > main.m:033: type error: argument has type `((func int) = int)',
> > main.m:033: expected type was `((func T) = int)'.
> > For more information, try recompiling with `-E'.
> >
> > I will now have a play with Fergus' approach.
>
> The problem is that bind/1 is not polymorphic - you can't know
> at compile time what type T it's going to be applied to.
>
> Perhaps a better solution is to change things as follows:
>
> :- typeclass token(T) where [
> func env(T) = int
> ].
>
The problem is that a place will need to bind to different environments
according to which location we wish to use that token in. This approach
only allows us to bind to one environment.
Here is the code from my first attempt, which might explain better what
I am trying to do.
% A single place in the petri net where tokens at this place
% have a type T.
%
:- type place(T)
---> place(
name :: string,
tokens :: tokens(T)
).
% An arc from a transition to a place where the type of the
% resulting token, as computed by the arc expression, is T.
%
% The existential type here is responsible for ensuring that the
% supplied higher order function and the place are compatible.
:- type arc_transition_place
---> some [T] arc_transition_place(
expression :: expression(T),
to :: ref(place(T))
).
% An arc from a place to a transition, where we use bind to bind
% a token of type t to some environment.
%
:- type arc_place_transition
---> some [T] arc_place_transition(
bind :: bind(T),
from :: ref(place(T))
).
%
% A transition uses all the incoming arcs bind functions to find
% a compatible environment. It then uses this environment to
% decide what tokens should be placed into the places determined
% by the outgoing arcs.
%
:- type transition
---> transition(
ingoing :: set(arc_place_transition),
outgoing :: set(arc_transition_place)
).
% An expression is a user defined function which maps the
% enviroment bound by all the incoming arcs to the set of tokens
% which should be placed into the destination place. It
% is possibly because we may not want to create a token at all.
%
:- type expression(T) == (func(environment) = set(T).
% bind(T) binds a token to an environment.
:- type bind(T) == (func(T) = environment).
:- type environment == int.
--------------------------------------------------------------------------
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