There is currently no instances for Ratio data type that can give us random values
Edit: - It looks like we are in a agreement that Uniform and UniformRange instances are not possible for Ratio. Question then is, should we add a Random instance, which doesn't really promise uniformity?
I can see a reasonable Uniform instance for integral types, which excludes the zero denominator:
instance (Integral a, Uniform a) => Uniform (Ratio a) where
uniformM g = do
n <- uniformM g
let notZero = do
d <- uniformM g
if d == 0 then notZero else pure d
(n %) <$> notZero
An efficient version for UniformRange needs some thought.
Note that neither Uniform, nor UniformRange would be able to generate Rational. This means that we can attempt and cook up such instance for Random
There is currently no instances for
Ratiodata type that can give us random valuesEdit: - It looks like we are in a agreement that
UniformandUniformRangeinstances are not possible forRatio. Question then is, should we add aRandominstance, which doesn't really promise uniformity?I can see a reasonable
Uniforminstance for integral types, which excludes the zero denominator:An efficient version for
UniformRangeneeds some thought.Note that neither
Uniform, norUniformRangewould be able to generateRational. This means that we can attempt and cook up such instance forRandom