hasty-hamiltonian

Speedy gradient-based traversal through parameter space.
Log | Files | Refs | README | LICENSE

commit 6f61629be2d820bcfd3f7212898866d19508f967
parent 9a6ff101f2bd99658d0f1ea49fec7a4f2d8804a8
Author: Jared Tobin <jared@jtobin.ca>
Date:   Tue, 20 Dec 2016 07:22:04 +1300

Generalize base monad.

Diffstat:
MCHANGELOG | 6+++++-
MNumeric/MCMC/Hamiltonian.hs | 12+++++++-----
Mhasty-hamiltonian.cabal | 2+-
Mstack-travis.yaml | 2+-
Mstack.yaml | 2+-
5 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG @@ -1,6 +1,10 @@ # Changelog +- 1.2.0 (2016-12-20) + * Generalize base monad requirement to something matching both MonadIO and + PrimState. + - 1.1.5 (2016-12-04) - * Simplify some constraints and add missing dependency bounds. + * Simplify some constraints and add missing dependency bounds. diff --git a/Numeric/MCMC/Hamiltonian.hs b/Numeric/MCMC/Hamiltonian.hs @@ -35,8 +35,9 @@ module Numeric.MCMC.Hamiltonian ( ) where import Control.Lens hiding (index) +import Control.Monad.IO.Class (MonadIO, liftIO) +import Control.Monad.Primitive (PrimState, PrimMonad) import Control.Monad.Trans.State.Strict hiding (state) -import Control.Monad.Primitive (PrimState, PrimMonad, RealWorld) import qualified Data.Foldable as Foldable (sum) import Data.Maybe (fromMaybe) import Data.Sampling.Types @@ -50,7 +51,8 @@ import qualified System.Random.MWC.Probability as MWC -- -- >>> withSystemRandom . asGenIO $ mcmc 3 1 [0, 0] target mcmc - :: (Num (IxValue (t Double)), Show (t Double), Traversable t + :: ( MonadIO m, PrimMonad m + , Num (IxValue (t Double)), Show (t Double), Traversable t , FunctorWithIndex (Index (t Double)) t, Ixed (t Double) , IxValue (t Double) ~ Double) => Int @@ -58,12 +60,12 @@ mcmc -> Int -> t Double -> Target (t Double) - -> Gen RealWorld - -> IO () + -> Gen (PrimState m) + -> m () mcmc n step leaps chainPosition chainTarget gen = runEffect $ chain step leaps Chain {..} gen >-> Pipes.take n - >-> Pipes.mapM_ print + >-> Pipes.mapM_ (liftIO . print) where chainScore = lTarget chainTarget chainPosition chainTunables = Nothing diff --git a/hasty-hamiltonian.cabal b/hasty-hamiltonian.cabal @@ -1,5 +1,5 @@ name: hasty-hamiltonian -version: 1.1.5 +version: 1.2.0 synopsis: Speedy traversal through parameter space. homepage: http://github.com/jtobin/hasty-hamiltonian license: MIT diff --git a/stack-travis.yaml b/stack-travis.yaml @@ -2,7 +2,7 @@ flags: {} packages: - '.' extra-deps: [] -resolver: lts-7.0 +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.0 +resolver: lts-7.14