[m-users.] Store type difficulties

Peter Wang novalazy at gmail.com
Sat Jul 4 13:23:07 AEST 2020

On Fri, 03 Jul 2020 16:47:28 -0700 "Patrick Henning" <pjhenning at fastmail.com> wrote:
> :- pred init_simple_exist(simple_exist).
> init_simple_exist(SimpleE) :-
>     store.init(Store),
>     SimpleE = simple_exist(Store).

As Zoltan said, you must construct a term involving an existentially
quantified functor like this:

    SimpleE = 'new simple_exist'(Store).

I wanted to add: I think most uses of mutvars in practice will use the
`io' type for the store, so you would just use an io_mutvar(T) to
contain values of type T. The problem with using other store types is
that as soon as you try to put them into another data structure, they
lose their uniqueness. Keeping the io state unique throughout your
program is not unreasonably difficult as there is support in the
standard library for threading ONE unique value around, e.g. list.foldl,
etc. but once you need to thread more than one unique value around you
run into a lot more difficulties.


More information about the users mailing list