Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate loaders for external modules #628

Open
AltGr opened this issue May 31, 2024 · 0 comments
Open

Generate loaders for external modules #628

AltGr opened this issue May 31, 2024 · 0 comments
Assignees
Labels
🏗️ build system Build system or Makefile 🔧 compiler Issue concerns the compiler ✨ enhancement New feature or request

Comments

@AltGr
Copy link
Collaborator

AltGr commented May 31, 2024

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:

  • when tasked with compiling a module tagged external, Catala would generate a "loader" module.
    • This module still takes care of doing the proper registrations and boilerplate (including module hash checks, which at the moment are bypassed for external modules) ;
    • it depends on an implementation module with a provided signature
    • the implementation of the actual functions are just forwarded to the implementation module
  • instead of providing a full Catala artefact with its strict requirements, the user now only supplies the "implementation" module, following the supplied signature

This 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.

@denismerigoux denismerigoux added ✨ enhancement New feature or request 🔧 compiler Issue concerns the compiler 🏗️ build system Build system or Makefile labels Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏗️ build system Build system or Makefile 🔧 compiler Issue concerns the compiler ✨ enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

2 participants