commit 5ba60758e429b385b252b461831eb6bc7fd30145
parent 28a4cb93f8badadd5f73d433818684584e959fe8
Author: Jared Tobin <jared@jtobin.ca>
Date: Sat, 30 Jun 2018 17:42:18 +1200
Use applicative instance for 'samples'.
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/System/Random/MWC/Probability.hs b/src/System/Random/MWC/Probability.hs
@@ -114,7 +114,7 @@ newtype Prob m a = Prob { sample :: Gen (PrimState m) -> m a }
-- >>> samples 2 uniform gen
-- [0.6738707766845254,0.9730405951541817]
samples :: PrimMonad m => Int -> Prob m a -> Gen (PrimState m) -> m [a]
-samples n model gen = replicateM n (sample model gen)
+samples n model gen = sequenceA (replicate n (sample model gen))
{-# INLINABLE samples #-}
instance Functor m => Functor (Prob m) where