[mercury-users] a typeclassful random.m

Julien Fischer juliensf at csse.unimelb.edu.au
Thu Feb 22 14:16:56 AEDT 2007

On Wed, 21 Feb 2007 doug.auclair at logicaltypes.com wrote:

> Dear all,
> I've been using Julian's typeclassed random.m, and I find myself
> using the following pattern when typeclassing arguments of a
> predicate:

typeclassing?  (Why not just constraining?)

> :- pred foo(arg1, ..., argN, RNG, RNG) <= prng(RNG, _).
> Julian may have the best answer here, but maybe others in the
> maillist have input, too -- is there a need to have the second
> argument at all in the typeclass?


> If so, what are the uses of the
> second argument, and how would it be used practically.

The second argument is the type of the seed of the random number 
generator.  You use it practically by passing a value of that type
to the seed method.

> Put another way: perhaps the protocol can be modified to
> provide the user a simpler typeclass specification of only one
> argument for the majority (in my case, for all) of uses?

I think that Julian's typeclass is wrong w.r.t the functional 
dependencies.  The seed type should be functionally dependent on the state 
of the random number generator but not the other way around.

mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au

More information about the users mailing list