ekmett / linear

Low-dimensional linear algebra primitives for Haskell.
http://hackage.haskell.org/package/linear
Other
200 stars 50 forks source link

Random instance for Linear.V #140

Closed bmabsout closed 5 years ago

bmabsout commented 7 years ago

Any reason why there's no random instance? this works for me:

instance (Dim n,Random m) => Random (V n m) where
    random = runState $ sequence (pure (state random))
    randomR (a,b) = runState $ sequence $ fmap state $ liftA2 (curry randomR) a b
Taneb commented 7 years ago

I presume you mean the Random in System.Random? That lives in the random package, which currently linear doesn't (directly) depend on.

bmabsout commented 7 years ago

yes from System.Random, it's a pretty useful instance though...

ekmett commented 5 years ago

Added in 98e3ddf as we have incurred an indirect dependency via vector anyways.