commit f36a49b36964484edf7dcb25ab1b6b116219fe75
parent 026626b6da6c1781930b404c15b0fcd0bb3bd904
Author: Jared Tobin <jared@jtobin.ca>
Date: Tue, 20 Dec 2016 07:21:43 +1300
Generalize base monad.
Diffstat:
5 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
@@ -1,6 +1,10 @@
# Changelog
+- 0.2.0 (2016-12-20)
+ * Generalize base monad requirement to something matching both MonadIO and
+ PrimState.
+
- 0.1.5 (2016-12-04)
- * Add missing dependency bounds.
+ * Add missing dependency bounds.
diff --git a/Numeric/MCMC/Slice.hs b/Numeric/MCMC/Slice.hs
@@ -1,4 +1,4 @@
--- {-# OPTIONS_GHC -Wall #-}
+{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE FlexibleContexts #-}
@@ -38,7 +38,8 @@ module Numeric.MCMC.Slice (
) where
import Control.Monad.Trans.State.Strict (put, get, execStateT)
-import Control.Monad.Primitive (PrimMonad, PrimState, RealWorld)
+import Control.Monad.Primitive (PrimMonad, PrimState)
+import Control.Monad.IO.Class (MonadIO, liftIO)
import Control.Lens hiding (index)
import Data.Maybe (fromMaybe)
import Data.Sampling.Types
@@ -55,18 +56,19 @@ import qualified System.Random.MWC.Probability as MWC
-- -9.310661272172682e-2,0.2562387977415508
-- -0.48500122500661846,0.46245400501919076
mcmc
- :: (Show (t a), FoldableWithIndex (Index (t a)) t, Ixed (t a),
+ :: (MonadIO m, PrimMonad m,
+ Show (t a), FoldableWithIndex (Index (t a)) t, Ixed (t a),
Num (IxValue (t a)), Variate (IxValue (t a)))
=> Int
-> IxValue (t a)
-> t a
-> (t a -> Double)
- -> Gen RealWorld
- -> IO ()
+ -> Gen (PrimState m)
+ -> m ()
mcmc n radial chainPosition target gen = runEffect $
chain radial Chain {..} gen
>-> Pipes.take n
- >-> Pipes.mapM_ print
+ >-> Pipes.mapM_ (liftIO . print)
where
chainScore = lTarget chainTarget chainPosition
chainTunables = Nothing
diff --git a/speedy-slice.cabal b/speedy-slice.cabal
@@ -1,5 +1,5 @@
name: speedy-slice
-version: 0.1.5
+version: 0.2.0
synopsis: Speedy slice sampling.
homepage: http://github.com/jtobin/speedy-slice
license: MIT
diff --git a/stack-travis.yaml b/stack-travis.yaml
@@ -2,7 +2,7 @@ flags: {}
packages:
- '.'
extra-deps: []
-resolver: lts-7.11
+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.11
+resolver: lts-7.14