Generic modules are parameterized modules that allow functionality for arbitrary types.
For generic modules, the generic parameters follows the module name:
It is also possible to parameterize by an int
or bool
constant, for example:
Code inside a generic module may use the generic parameters as if they were well-defined symbols:
Including a generic module works as usual:
Just like for macros, optional constraints may be added to improve compile errors: