commit 7470e0f7e95de07413526ba9dfdf5947776b0b4f
parent 7a61ebeed932f8ae22abba5810f3e2365fc671c3
Author: Jared Tobin <jared@jtobin.ca>
Date: Tue, 20 Dec 2016 07:42:16 +1300
Generalize base monad.
Diffstat:
5 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
@@ -1,7 +1,10 @@
# Changelog
+- 1.5.0 (2016-12-20)
+ * Generalize base monad.
+
- 1.4.0 (2016-12-01)
- * Export the 'particle' and 'ensemble' helper aliases to make it a little
- less burdensome to create an origin for a Markov chain.
+ * Export the 'particle' and 'ensemble' helper aliases to make it a little
+ less burdensome to create an origin for a Markov chain.
diff --git a/flat-mcmc.cabal b/flat-mcmc.cabal
@@ -1,5 +1,5 @@
name: flat-mcmc
-version: 1.4.2
+version: 1.5.0
synopsis: Painless general-purpose sampling.
homepage: https://github.com/jtobin/flat-mcmc
license: MIT
diff --git a/lib/Numeric/MCMC/Flat.hs b/lib/Numeric/MCMC/Flat.hs
@@ -42,10 +42,11 @@ module Numeric.MCMC.Flat (
) where
import Control.Monad (replicateM)
+import Control.Monad.IO.Class (MonadIO, liftIO)
import Control.Monad.Par (NFData)
import Control.Monad.Par.Combinator (parMap)
import Control.Monad.Par.Scheds.Sparks hiding (get)
-import Control.Monad.Primitive (PrimMonad, PrimState, RealWorld)
+import Control.Monad.Primitive (PrimMonad, PrimState)
import Control.Monad.Trans.State.Strict (get, put, execStateT)
import Data.Monoid
import Data.Sampling.Types as Sampling.Types hiding (Chain(..))
@@ -206,11 +207,17 @@ chain = loop where
-- -1.1655594505975082,1.1655594505975082
-- 0.5466534497342876,-0.9615123448709006
-- 0.7049046915549257,0.7049046915549257
-mcmc :: Int -> Ensemble -> (Particle -> Double) -> Gen RealWorld -> IO ()
+mcmc
+ :: (MonadIO m, PrimMonad m)
+ => Int
+ -> Ensemble
+ -> (Particle -> Double)
+ -> Gen (PrimState m)
+ -> m ()
mcmc n chainPosition target gen = runEffect $
chain Chain {..} gen
>-> Pipes.take n
- >-> Pipes.mapM_ (T.putStrLn . render)
+ >-> Pipes.mapM_ (liftIO . T.putStrLn . render)
where
chainTarget = Target target Nothing
{-# INLINE mcmc #-}
diff --git a/stack-travis.yaml b/stack-travis.yaml
@@ -2,8 +2,8 @@ flags: {}
packages:
- '.'
extra-deps: []
-resolver: lts-5.2
-compiler: ghc-7.10.3
+resolver: lts-7.14
+compiler: ghc-8.0.1
system-ghc: false
install-ghc: true
diff --git a/stack.yaml b/stack.yaml
@@ -2,4 +2,4 @@ flags: {}
packages:
- '.'
extra-deps: []
-resolver: lts-7.9
+resolver: lts-7.14