# Tidal's monad(s), or: unwrap vs. squeezeJoin

**URL:** <https://forum.toplap.org/t/tidals-monad-s-or-unwrap-vs-squeezejoin/1112>\
**Category:** TidalCycles\
**Created:** [20 February 2020 11:18 UTC](https://forum.toplap.org/t/tidals-monad-s-or-unwrap-vs-squeezejoin/1112 "2020-02-20T11:18:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwaldmann](https://forum.toplap.org/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@jwaldmann](https://forum.toplap.org/u/jwaldmann)\
**Post date:** [20 February 2020 11:18 UTC](https://forum.toplap.org/t/tidals-monad-s-or-unwrap-vs-squeezejoin/1112/1 "2020-02-20T11:18:45Z")

</div>

Hi. I wrote a short text on the applicative and monadic structure of Tidal patterns. It compares `unwrap` with `squeezeJoin`.  
[https://www.imn.htwk-leipzig.de/~waldmann/etc/untutorial/tc/monad/](https://www.imn.htwk-leipzig.de/~waldmann/etc/untutorial/tc/monad/) . Comments welcome. - J.W.

---

<div class="post-metadata">

**Author:** ![yaxu](https://forum.toplap.org/user_avatar/forum.toplap.org/yaxu/32/3_2.png) [@yaxu](https://forum.toplap.org/u/yaxu)\
**Post date:** [21 February 2020 12:36 UTC](https://forum.toplap.org/t/tidals-monad-s-or-unwrap-vs-squeezejoin/1112/2 "2020-02-21T12:36:58Z")

</div>

Wow looking forward to reading this, just commenting on very strange synchronicity as we were just discussing this very topic on the chat ! [https://chat.toplap.org/channel/tidal?msg=pJx6hYkkvk3E82KyQ](https://chat.toplap.org/channel/tidal?msg=pJx6hYkkvk3E82KyQ)

---

<div class="post-metadata">

**Author:** ![yaxu](https://forum.toplap.org/user_avatar/forum.toplap.org/yaxu/32/3_2.png) [@yaxu](https://forum.toplap.org/u/yaxu)\
**Post date:** [21 February 2020 12:54 UTC](https://forum.toplap.org/t/tidals-monad-s-or-unwrap-vs-squeezejoin/1112/3 "2020-02-21T12:54:59Z")

</div>

Just reading through… Firstly I’d say that this hasn’t been discussed very much. I’m a self-taught haskell programmer, and haven’t had enough interaction with the Haskell community. When I have I’ve learned a lot! E.g. from this post, although Tidal’s representation has changed a lot since then [https://ryani.livejournal.com/19471.html](https://ryani.livejournal.com/19471.html)

I didn’t really understand the section “More Operations on Patterns” - `<*`,` *>` and `<*>` are about ‘wholes’ rather than values. They control what happens if you combine two events of different sizes. The new event always ends up as the intersection of the two events. But tidal also remembers the original ‘whole’ of which an event is a part (or fragment) of. With `<*>`, the whole is an intersection of the two wholes. With `<*` the whole is taken from the left, with `*>` it’s taken from the right. This is something I’ve worked out relatively recently…

_editing this as I read through…_

This is interesting:

```haskell
run 8 # irand 2

```

`#` will combine the two patterns but throw away all the values from the one on the left, only taking its structure. `irand 2` is continuous and doesn’t have structure. I think you’re using `run` to turn a pattern into with a continuously varying value into one with discrete events? The idiomatic way to do this would be `segment 8 $ irand 2`

In general I haven’t fully thought through what should happen when combining continuous and discrete events… So converting everything to discrete events is a good idea!

Anyway, thanks @jwaldmann for clarifying all this. clarissaAdjoint on the chat was also looking at `unwrap`, `innerJoin`, `outerJoin` and `squeezeJoin`, and found that the latter is the only one that currently seems to meet the monad laws, so perhaps that should become the ‘default’ one.

There’s a _lot_ of use of the applicative instance, but in practice I don’t know of anyone actually using the Tidal monad instance, perhaps there is some useful UI to discover in this…

---

<div class="post-metadata">

**Author:** ![jwaldmann](https://forum.toplap.org/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@jwaldmann](https://forum.toplap.org/u/jwaldmann)\
**Post date:** [21 February 2020 13:17 UTC](https://forum.toplap.org/t/tidals-monad-s-or-unwrap-vs-squeezejoin/1112/4 "2020-02-21T13:17:46Z")

</div>

Hi Alex. Thanks for replying. Here’s another coincidence: my friend Heinrich told me (just yesterday) that he was investigating Functorial structure for music and gave a presentation at FARM 2019, see [https://github.com/HeinrichApfelmus/cnoidal](https://github.com/HeinrichApfelmus/cnoidal) .

---

<div class="post-metadata">

**Author:** ![yaxu](https://forum.toplap.org/user_avatar/forum.toplap.org/yaxu/32/3_2.png) [@yaxu](https://forum.toplap.org/u/yaxu)\
**Post date:** [22 February 2020 11:04 UTC](https://forum.toplap.org/t/tidals-monad-s-or-unwrap-vs-squeezejoin/1112/5 "2020-02-22T11:04:20Z")

</div>

Great!  
Just to correct myself - I misunderstood, unwrap and squeezeJoin meet the laws but inner and outer join do not. I wonder if there are other possible monadic joins?
