Generate loaders for external modules #628
Labels
🏗️ build system
Build system or Makefile
🔧 compiler
Issue concerns the compiler
✨ enhancement
New feature or request
Ref. #482
At the moment, we have support for externally implemented modules in a very raw form: an escape hatch allows to provide directly the ml artifact for the module that Catala would normally generate.
The next improvement would provide a nicer interface to external modules, and avoid the need for the user to copy-paste boilerplate and registration code into their module:
external
, Catala would generate a "loader" module.implementation
module with a provided signatureThis avoids boilerplate in the user code, improves compilation checks, clarifies requirements upon the user implementation (including if e.g. catala identifiers diverge from ocaml identifiers for some reason), and typing errors can be detected and debugged much more naturally (ie pointing the definition not having the correct type instead of some usage not typing somewhere in generated code).
There is one issue, though: the user code may need to depend, at least in some way, upon some Catala declarations: the functions to be supplied may have to manipulate types defined in Catala. This could be handled nicely be requiring the user to supply a functor with a given type: all type declarations corresponding to struct/enums defined in the current module could be exposed through the functor argument.
Extending this, we could allow external modules to depend on other Catala modules... if they need to manipulate the structures or enums they define.
The text was updated successfully, but these errors were encountered: