ITADN

V2 is not an instance of Uniform or UniformRange.

#182Closedvladov3000 创建于 2025-01-22
V
vladov3000commented
I am trying to generate a random point in a rectangle. I would like to write the the following code: ```haskell randomPoint :: UniformRange a => V2 a -> V2 a -> V2 a randomPoint topLeft bottomRight = uniformRM (topLeft, bottomRight) globalStdGen ``` However, `Linear.V2` is not an instance of `UniformRange`. It implements `Random`, which only exists for backwards compatibility reasons: > Random exists primarily for backwards compatibility with version 1.1 of this library. In new code, use the better specified Uniform and UniformRange instead. I can add `Uniform` and `UniformRange` instances for `V2` and the other vector types myself if you would like. Links: [Random](https://hackage.haskell.org/package/random-1.2.1.2/docs/System-Random.html#t:Random) [Uniform](https://hackage.haskell.org/package/random-1.2.1.2/docs/System-Random.html#t:Uniform) [UniformRange](https://hackage.haskell.org/package/random-1.2.1.2/docs/System-Random.html#t:UniformRange)
关闭于 2025-01-24 2 条评论