Skip to content

Conversation

@turion
Copy link
Collaborator

@turion turion commented May 16, 2023

With this PR, it should be possible to derive the MonadMeasure class easily for any monad transformer.

random = lift random
bernoulli = lift . bernoulli
categorical = lift . categorical
uniformD = lift . uniformD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only note here would be that some of the previous lifting instances appear to have varied slightly. This actually may have been my doing, because I recall that working in a transformed Enumerator didn't lift bernoulli, so that discrete distributions got calculated via random and thus failed with enumerate.


instance (MonadTrans t, MonadDistribution m, Monad (t m)) => MonadDistribution (MonadMeasureTrans t m) where
random = lift random
uniform = (lift .) . uniform
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly here, there may have been a reason that many of the instances were limited to mostly just lift random. This doesn't change the denotational semantics, but may have efficiency implications, so make sure to benchmark, particularly PMMH and RMSMC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants