Hey! In ReScript/ReasonML/OCaml file names are always modules and folders do not mean anything from namespacing point of view.
If you want the module structure you described, you need to have exactly these two files
Customers.res
Administrators.res
Both files then contain two modules, Profile and Settings.
On the other hand, if you (will) have huge amount of files and wish to create a folder structure, you still need to namespace each individual file as they were all in the root. A popular strategy is to do something like this:
Ah, my bad. It is indeed possible by using the “proxy” modules. I’ve even used that approach, so that makes it even more embarrassing (I’ll edit my answer)
Exactly! Since all file names in the project are unique and globally available, it doesn’t really make sense to impose an arbitrarily nested directory hierarchy, and as long as you are not running with hundreds of modules, just keep it simple and put everything e.g. in a single components / bindings folder etc.
Advantage of this is that you don’t need to follow around module aliases and it’s extremely easy to find files (e.g. you are using somewhere, just fuzzy search for ArticleCard and the first hit is your file).
It’s really relieving to not think about logical units such as folders every time and it will spare you a lot of time refactoring your code later when you suddenly realize that those components should be called differently etc.
Also being able to later move files freely around in the source folder or making a nested module its own file without the need to update references on it is very nice. One of the features I really miss in other languages.
Hey, old topic but I just came across this - what’s the deal with double vs single underscores. I see some using double underscores and some using a single. Is that just preference or is it convention for something?
I believe the convention comes from OCaml where modules are named In_Pascal_Case_with_Underscores. So the double underscore clearly separates two modules having such names.
In ReScript it’s more conventional to has just RegularPascalCase, so a single underscore is enough.
I saw no explicit recommendation to use one or two underscores for module nesting in ReScript.