[mercury-users] Promise on a typeclass method?

doug.auclair at logicaltypes.com doug.auclair at logicaltypes.com
Wed Jun 7 01:30:09 AEST 2006


Dear all,

Is there a way to enforce that an implementation of a
typeclassed predicate will always return a (e.g.)
particular range?

Specifically, in qcheck2 (see http://www.logicaltypes.com),
the RNG typeclass is the following:

:- typeclass random_number_generator(RNG) where [
        % gives a random float in the range [0, 1)
        pred rnd(float::out, RNG::in, RNG::out) is det,
        pred reseed(int::in, RNG::unused, RNG::out) is det
].

How can demand that an implementer of rnd/3 will only return
floats between 0.0 and 1.0?  In aspect-oriented programming
(see http://eclipse.org/aspectj for aspects and see 
http://www.cotilliongroup.com/man/aspects/aspects-man.html
for aspects in Prolog), one would wrap rnd/3 in a production
aspect so that every time rnd/3 is called the aspect would
ensure the value returned is within the range.  How does one
do this with Mercury constructs?

Sincerely,
Doug Auclair

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