Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add newtype to lift classes to monad transformers #272

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

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.

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