Maintaining state in a deep map

You don’t have to colocate the functions that manipulate the struct in the same module that defines the struct. I frequently have one module with several sub-modules, all defined in the same file. The sub-modules have nothing but a struct, and all the business logic reside in the main module.

As for updating a struct couple levels deep, if you don’t like put_in/3 and update_in/3, there are fancier libraries that help with ergonomics. One was recently discussed in this forum:

3 Likes