# A Tree for TEA (tea-tree)

**URL:** <https://discourse.elm-lang.org/t/a-tree-for-tea-tea-tree/1427>\
**Category:** Request Feedback\
**Created:** [June 26, 2018, 2:04pm UTC](https://discourse.elm-lang.org/t/a-tree-for-tea-tea-tree/1427 "2018-06-26T14:04:12Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![rupert](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/rupert/32/1775_2.png) [@rupert](https://discourse.elm-lang.org/u/rupert)\
**Post date:** [June 27, 2018, 10:19am UTC](https://discourse.elm-lang.org/t/a-tree-for-tea-tea-tree/1427/9 "2018-06-27T10:19:48Z")

</div>

> [@Erkal\_Selman](#):
>
> What does this tree have to do with the elm architecture?

The answer to that is found in this discussion:

> [@Update a node in a tree](https://discourse.elm-lang.org/t/update-a-node-in-a-tree/1401):
>
> I was trying to learn more Elm with a toy project, but I ran into an conceptual issue. This is the first time that I have a problem in Elm that I know how to solve in other languages, but not at all in Elm. The project is a [tournament planner (not too great code, yet)](https://glitch.com/edit/#!/wettbuero) that will let you play against your friends. Of course, a central part is the tournament tree, which I implemented quite naturally as a recursive tree structure. The issue is when I want to update a node. My intuitive approach (w…

It is designed to work nicely with the Elm update cycle, where deltas to the Model are passed as Msgs. The specific problems being addressed are, how to avoid capturing stale state in the Msgs, how to be certain when re-visiting a node that the right one is being re-visited, and how to do this efficiently. The first problem is solved by only passing a Path with the Msgs, that described where in the tree an update is to be applied without capturing the state at that node. The other problems are solved by assigning unique ids to all nodes that act like references.

> [@Erkal\_Selman](#):
>
> I mean this would also make sense in a language like Haskell or ML without any relation to TEA. Or am I mistaken?

This tree implementation is only needed because multiple Msgs can be triggered against the same instance of the Model. It would be more normal to use a rose-tree in situations where that is not the case.

---

_[View the full topic](https://discourse.elm-lang.org/t/a-tree-for-tea-tea-tree/1427)._
