This is more of a personal/philosophical question than a technical problem. When you’re building something new with OCaml, at what point do you write an interface file for your module?
Do you start with the interface file, and then fill in the implementation later? How far do you go before you start implementing the interface? Do you instead try to get something working first, and only then think about how to modularize it and define the interfaces between modules? Or is it a mix of both? Are there any rules of thumb that you follow?
I’m new to OCaml, and really enjoying it so far. However I find myself falling into the trap of spending too much time designing and documenting .mli files, only to later find, when implementing them, that I hadn’t considered some drawback to the interface, and have to throw out some work. I’m prone to do this in every language, but it seems even more tempting in OCaml to spend all of my time designing interfaces. It might come from the clear separation between .mli and .ml files – in other languages, the implementation and interface are mixed together in the same file, so both stay on my mind.
I’m not really asking for any kind of solution, I’m just curious about others’ habits.