tweag / monad-bayes

A library for probabilistic programming in Haskell.
MIT License
410 stars 62 forks source link

Renaming `MonadSample` and `MonadInfer` #197

Closed reubenharry closed 2 years ago

reubenharry commented 2 years ago

I'm not a huge fan of the names MonadSample and MonadInfer. On the one hand, it's nice to keep aligned with the original paper. But on the other, they're a little misleading. MonadSample isn't inherently about sampling.

I'd proposed the names MonadDistribution and MonadMeasure respectively.

The downsides of these are:

Finally I'd replace MonadCond with MonadFactor.

mknorps commented 2 years ago

I the library there is already a more informative type signatures for some of the use cases (see HERE):

type Distribution a = forall m. MonadSample m => m a

type Measure a = forall m. MonadInfer m => m a

type Kernel a b = forall m. MonadInfer m => a -> m b

Do you find adding Monad prefix more Haskelly? Another option to go with the Haskell style is adding a suffix M indicating we are in a monadic context. Then we would have DistributionM, MeasureM, etc.

reubenharry commented 2 years ago

That's true - I added Distribution etc in Class.hs, but they're a bit restrictive because you can't write e.g. a -> Distribution b for a conditional distribution, and instead have to use Kernel.

I think for typeclasses, the convention is MonadX, as in MonadReader, MonadState, etc, but for functions, it's xM.

mknorps commented 2 years ago

You are right @reubenharry! I found a summary on Kowainik blog. As for adding Monad prefix for typeclasses it is used when a typeclass has mtl style effects, so all is good.