System.Random instances for tuples
aslatter at gmail.com
Tue Apr 17 04:55:32 CEST 2012
On Mon, Apr 16, 2012 at 9:04 PM, Dan Burton <danburton.email at gmail.com> wrote:
> Ever find yourself wanting to generate a tuple of random things? Instances
> are trivial to write in Haskell 98:
CC'ing the maintainer of the package as well.
It looks like it makes sense to me.
> instance (Random a, Random b) => Random (a, b) where
> randomR ((loL, loR), (hiL, hiR)) g = ((l, r), g'')
> where (l, g') = randomR (loL, hiL) g
> (r, g'') = randomR (loR, hiR) g'
> random g = ((l, r), g'')
> where (l, g') = random g
> (r, g'') = random g'
> Can we add instances like this to System.Random in the random package?
> -- Dan Burton
> Libraries mailing list
> Libraries at haskell.org
More information about the Libraries