Skip to content

Commit

Permalink
Add PrimMonad instance for the strict SamplerT
Browse files Browse the repository at this point in the history
  • Loading branch information
0xd34df00d committed Jan 4, 2025
1 parent a53aef9 commit 0850075
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Control/Monad/Bayes/Sampler/Strict.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE UndecidableInstances #-}

-- |
-- Module : Control.Monad.Bayes.Sampler
Expand Down Expand Up @@ -43,6 +45,7 @@ import Control.Monad.Bayes.Class
( uniformR
),
)
import Control.Monad.Primitive (PrimMonad)
import Control.Monad.Reader (MonadIO, ReaderT (..))
import Control.Monad.ST (ST)
import Control.Monad.Trans (MonadTrans)
Expand All @@ -52,7 +55,7 @@ import System.Random.Stateful (IOGenM (..), STGenM, StatefulGen, StdGen, initStd

-- | The sampling interpretation of a probabilistic program
-- Here m is typically IO or ST
newtype SamplerT g m a = SamplerT {runSamplerT :: ReaderT g m a} deriving (Functor, Applicative, Monad, MonadIO, MonadTrans)
newtype SamplerT g m a = SamplerT {runSamplerT :: ReaderT g m a} deriving (Functor, Applicative, Monad, MonadIO, MonadTrans, PrimMonad)

-- | convenient type synonym to show specializations of SamplerT
-- to particular pairs of monad and RNG
Expand Down

0 comments on commit 0850075

Please sign in to comment.