// ListStack.res
module __ListStack: Stack = {
}
include __ListStack
But do you need it at all? Unlike records, modules in ReScript are structurally typed, so if it walks like a duck…
The only thing the annotation probably gets you is that if your implementation doesn’t match the Stack spec, type checking will fail earlier than, say, passing unannotaded ListStack to a functor expecting Stack.
Interfaces in ReScript are used solely to hide things. Or abstract details away, if you will. Interfaces do not add any information, they only remove it from outside view.
It can also be handy to ensure that an implementation conforms to some interface though, and a module type can be useful to avoid duplicating interface code. Using a module type makes sense here if you want to ensure that you can swap one implementation out for the other without compilation errors, but it’s not strictly necessary.
To do so in a separate file you can simply add an interface file (.resi) and include the module type in it: