On 09-Jul-2001, Norman Ramsey <[EMAIL PROTECTED]> wrote:
> I'm trying to model probability and leave the
> representation of probability unspecified other than
> it must be class Real.  But I'm having trouble with
> random numbers; how can I show that if a type has class Real,
> it also has class Random.Random?  Is there a way to accomplish
> this goal other than by changing the library?

I'm not sure if I fully understand your goal.
But one thing you can do is to define a wrapper type

        newtype WrapReal r = WrapReal r

and make the wrapper an instance of Random.Random
if the underlying type is an instance of Real

        instance Real r => Random.Random (WrapReal r) where
                ...

Then you can use the wrapper type whenever you want to get a random number.

-- 
Fergus Henderson <[EMAIL PROTECTED]>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.

_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to