You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is the lazy sampler actually a monad? I believe it doesn't satisfy the monad laws:
ghci> import Control.Monad.Bayes.Sampler.Lazy
ghci> import System.Random
ghci> g <- newStdGen
ghci> let prog = (Control.Monad.Bayes.Class.random :: Control.Monad.Bayes.Sampler.Lazy.Sampler Double) >>= return
ghci> let prog' = (Control.Monad.Bayes.Class.random :: Control.Monad.Bayes.Sampler.Lazy.Sampler Double)
ghci> runSampler prog $ randomTree g
0.7318877896125477
ghci> runSampler prog' $ randomTree g
0.23172949590893044
Even worse, it's not even a functor with liftM:
ghci> runSampler (liftM id prog) $ randomTree g
0.6649028878458447
This is because depending on how we construct the program, the random number generator gets split or not. But this is not coassociative (there are no nontrivial comonoids in Haskell) and thus the monad laws don't hold.
The text was updated successfully, but these errors were encountered:
This sounds like an issue to take up with Sam Staton and his students - this code comes from their work on LazyPPL, and since they're into denotational semantics, this seems like a thing they'd care about. I've previously been in touch with them, so definitely something we could just ask them.
Is the lazy sampler actually a monad? I believe it doesn't satisfy the monad laws:
Even worse, it's not even a functor with
liftM
:This is because depending on how we construct the program, the random number generator gets split or not. But this is not coassociative (there are no nontrivial comonoids in Haskell) and thus the monad laws don't hold.
The text was updated successfully, but these errors were encountered: