# Blog post: Playing With a Game (mainly math, some Haskell)

**URL:** <https://discourse.haskell.org/t/blog-post-playing-with-a-game-mainly-math-some-haskell/10407>\
**Category:** Links\
**Created:** [September 24, 2024, 6:28pm UTC](https://discourse.haskell.org/t/blog-post-playing-with-a-game-mainly-math-some-haskell/10407 "2024-09-24T18:28:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cdsmith](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/cdsmith/32/1519_2.png) [@cdsmith](https://discourse.haskell.org/u/cdsmith)\
**Post date:** [September 24, 2024, 6:28pm UTC](https://discourse.haskell.org/t/blog-post-playing-with-a-game-mainly-math-some-haskell/10407/1 "2024-09-24T18:28:29Z")

</div>

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.

> **[Playing With a Game](https://cdsmithus.medium.com/playing-with-a-game-0dd944082e2c)**
>
> In a recent comment (that I sadly cannot find any longer) in https://www.reddit.com/r/math/, someone mentioned the following game. There…

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.

---

<div class="post-metadata">

**Author:** ![olf](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/olf/32/3813_2.png) [@olf](https://discourse.haskell.org/u/olf)\
**Post date:** [September 25, 2024, 5:58pm UTC](https://discourse.haskell.org/t/blog-post-playing-with-a-game-mainly-math-some-haskell/10407/2 "2024-09-25T17:58:35Z")

</div>

Yes, please do share when Haskell can serve to make mathematics palpable. We should see more of this in schools. [play.haskell.org](http://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:

```haskell
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

```haskell
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](https://github.com/lazyppl-team/lazyppl/blob/master/src/LazyPPL.hs) library.

---

<div class="post-metadata">

**Author:** ![ocramz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/ocramz/32/3713_2.png) [@ocramz](https://discourse.haskell.org/u/ocramz)\
**Post date:** [September 26, 2024, 3:15am UTC](https://discourse.haskell.org/t/blog-post-playing-with-a-game-mainly-math-some-haskell/10407/3 "2024-09-26T03:15:57Z")

</div>

Interesting! Just a question on naming: why is this defined as a “game”, when there is really a single turn and the participants are independent?

---

<div class="post-metadata">

**Author:** ![cdsmith](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/cdsmith/32/1519_2.png) [@cdsmith](https://discourse.haskell.org/u/cdsmith)\
**Post date:** [September 26, 2024, 12:58pm UTC](https://discourse.haskell.org/t/blog-post-playing-with-a-game-mainly-math-some-haskell/10407/5 "2024-09-26T12:58:36Z")

</div>

I think it’s a fairly standard use of terminology? [Simultaneous game - Wikipedia](https://en.wikipedia.org/wiki/Simultaneous_game) for example.
