[m-dev.] for review: use bitsets in quantification

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Nov 3 23:58:46 AEDT 2000


On 03-Nov-2000, Ralph Becket <rbeck at microsoft.com> wrote:
> >From Fergus Henderson on 03/11/2000 08:45:04
> > > +:- typeclass enum(T) where [
> > > +	func to_int(T) = int,
> > > +	func from_int(int) = T
> > > +].
> > 
> > The documentation and interface here suggests that only types which
> > are isomorphic to `int' are allowed, and that `from_int' can't fail.
> > But I think the intent is that this typeclass should be allowed
> > for types which are isomorphic to a subrange of `int'.
> > The `from_int' function should be semidet, and you should
> > document when it should fail.
> 
> I'd rather keep from_int/1 det and see an extra predicate or two added:
> 
> 	pred convert_int(int::in, T::out) is semidet

Well, the type class method (whatever it is called) should be
semidet.  If you want a det version that calls error if the
conversion fails, then it should just be an ordinary procedure
rather than a type class method.  I agree that such a procedure
would be useful.  There's room for debate about what the names
of these procedures should be.

> 	pred int_is_enum_image(int::in) is semidet

That one doesn't work: there's no enum argument, so there's no way to
specify which enum type you mean.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "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