[m-dev.] Revisiting `any' and inst casts for solver types
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Jun 3 13:00:42 AEST 2004
On 01-Jun-2004, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> So here's yet another suggestion. We start with some syntax like this:
>
> :- solver type <<solver type name and params>>
> where representation is <<representation type name and args>>,
> ground is <<ground inst>>,
> any is <<any inst>>,
> equality is ...
>
> This says that
> - <<solver type>> is implemented using <<representation type>>,
> - a `ground' <<solver type>> value has a corresponding <<ground inst>>
> <<representation type>> value,
> - an `any' <<solver type>> value has a corresponding <<any inst>>
> <<representation type>> value.
Sounds fine so far.
> The compiler will treat `church' as an opaque foreign type and will
> construct a predicate to handle conversion between `church' and its
> internal representation `ch':
>
> :- impure pred 'church/0 representation'(church, ch ).
> :- mode 'church/0 representation'(in(any), out(any_ch) ) is det.
> :- mode 'church/0 representation'(out(any), in(any_ch) ) is det.
> :- mode 'church/0 representation'(in, out(ground_ch)) is det.
> :- mode 'church/0 representation'(out, in(ground_ch) ) is det.
Note that if you give this predicate slightly different modes,
it need not be impure:
:- pure pred 'church/0 representation'(church, ch ).
:- mode 'church/0 representation'(in(any), out(any_ch) ) is cc_multi.
:- mode 'church/0 representation'(out(any), in(any_ch) ) is det.
:- mode 'church/0 representation'(in, out(ground_ch)) is cc_multi.
:- mode 'church/0 representation'(out, in(ground_ch) ) is det.
However, using `promise_pure' is in many cases a lot easier than using
`promise_only_solution', so until we have a better alternative to
`promise_only_solution', you may prefer to use the impure approach.
> Otherwise, everything is much the same as before.
Would you mind reposting your description of those parts?
--
Fergus Henderson | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list