I was wondering if it’s possible to generate random tuples with a code like:
take 4 $ randomRs ((0,0),(70,100)) $ mkStdGen x :: [(Double,Double)]
when I try this one I get the error:
No instance for (Random (Float, Float)) arising from a use of 'randoms'
Is there a way to get random tuples without using zip?
Basically the error message is saying that there isn’t a defined way of making random tuples. But you can of course add one yourself.
Off the top of my head (i.e., I haven’t actually tested this), you can do something like
Now you can use
randomRon tuples (provided that the types in the tuple support random generation).