mwc-probability

Sampling function-based probability distributions.
Log | Files | Refs | README | LICENSE

commit 0a2a9085a46c8ac3d9b40eb3471ad8a783ffa16b
parent e16b6078340bc2fb5f840a0edf75971368cd560b
Author: Jared Tobin <jared@jtobin.ca>
Date:   Tue,  4 Aug 2015 12:35:04 -0230

Misc updates.

*  Update .gitignore
*  Add stack.yaml
*  Add Num instance for Prob

Diffstat:
M.gitignore | 1+
Msrc/System/Random/MWC/Probability.hs | 8++++++++
Astack.yaml | 5+++++
3 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -3,3 +3,4 @@ dist *swp cabal.sandbox.config debug +.stack-work diff --git a/src/System/Random/MWC/Probability.hs b/src/System/Random/MWC/Probability.hs @@ -47,6 +47,14 @@ instance Monad m => Applicative (Prob m) where {-# INLINE pure #-} {-# INLINE (<*>) #-} +instance (Applicative m, Monad m, Num a) => Num (Prob m a) where + (+) = liftA2 (+) + (-) = liftA2 (-) + (*) = liftA2 (*) + abs = fmap abs + signum = fmap signum + fromInteger = pure . fromInteger + instance Monad m => Monad (Prob m) where return = Prob . const . return m >>= h = Prob $ \g -> do diff --git a/stack.yaml b/stack.yaml @@ -0,0 +1,5 @@ +flags: {} +packages: +- '.' +extra-deps: [] +resolver: lts-2.21