I work at a company called Zaptic and our internal modules are namespaced in a few different ways. We have some core domain types & decodes (eg. Users, Campaigns, Teams, Reports) under a Data. namespace so:
Data.User
Data.Campaign
...
We also have two main Elm apps called Business and Users so we have:
We also have a series of utility modules under a Zap namespace. So:
Zap.Upload
Zap.File
Zap.Icons
...
This is a mixture of legacy (I think Data was perhaps inspired by Haskell’s Data. namespace though I feel that is probably more for reusable generic data structures) and copying NoRedInk (I think they have a Nri namespace for some stuff?) and then just have actual apps that feel like they should be top level.
My question is, how do you all approach this? Similar strategy or notably different? I also have a colleague who feels that we should try to remove the top level namespaces but I’m concerned about conflicting with 3rd party packages and honestly I like the visual separation of 1st & 3rd party packages in the import block. That said, we do a lot of import Data.User as User and both feel it would be nice to have import Business.UnitType.Model as UnitType.Model but you can’t have dots in aliases (probably sensible!)
Anyway, this all comes up in conversation a bit between my colleague and I and it would be great to have some other voices and input around different strategies to help us move the conversation forwards
I don’t have too much to add but I’m also interested in the thoughts of others. I suspect there is something of a dichotomy of preferences, some people like very structured module hierarchies whilst others prefer not to have any “unnecessary” structure. I’m personally in the second camp because I feel it’s easier to change the structure the simpler it is.
Despite that preference, I personally find your current structure fine, I also quite like the visual separation of 1st and 3rd party modules. Perhaps instead of “unnecessary structure” I mean “structure with no obvious benefit”.
Your concern about conflicting with 3rd party modules is fair, though you could always simply rename your module(s) when a conflict arises, it won’t be that much work. There is an open issue concerning resolution in such circumstances: https://github.com/elm/compiler/issues/1625 there it talks about a conflict with two packages having clashing module names, and therefore you cannot import either one and unlike the case with code you own you cannot change either one.