I thought I’d share this. It’s primarily about a game theory question, but ends up making some mildly interesting use of a probability library Shae Erisson and I wrote together when we used to get together to hack on random stuff on the weekends.
Let me know if people are interested in seeing this kind of haskell-plus content posted here in the future. Also, the library here isn’t on Hackage because there are already more well-known probability monads on Hackage, but this one is nice in a few ways, such as handling left recursion. I’m open to feedback on whether the value is greater than the cost in Hackage namespace and package dilution.
Yes, please do share when Haskell can serve to make mathematics palpable. We should see more of this in schools. play.haskell.org has greatly lowered the barrier of sprinkling some Haskell into a lesson.
The blog post is maybe not the right place to mention that, but your Distribution monad is the free monad over the functor that provides the basic affine combination:
data Affine prob x = Affine prob x x
type Distribution prob s = Free (Affine prob) s
Hence every monad P that has an algebra structure
affine :: Affine prob (P x) -> P x
should have a monad morphism Distribution prob s -> P s.
Conceptually, by virtue of the infinite tree structure, Distribution is related to the monad used in the LazyPPL library.