package catala

  1. Overview
  2. Docs
Compiler and library for the literate programming language for tax code specification

Install

dune-project
 Dependency

Authors

Maintainers

Sources

1.1.0.tar.gz
md5=ec7dda88c5f7f371d2a35874cdae2a10
sha512=7cedccfbe5330992d5730441d6ba7b97446237ff5bb4579498a167f2319ec03e8fae50b7f80e3abe96833744b61ffd10719ce0c3e4c144893a4b7adc77e91b56

doc/plugins.html

Example backend plugins

This directory contains backend plugins that demonstrate how those can be written and used with Catala.

Use make plugins from the root of the source tree to build them.

A plugin is created by writing an OCaml module that calls Driver.Plugin.register and that links against catala.driver. Here is an example dune stanza to compile it:

(library
 (name my-plugin)
 (modules my_plugin_main_module)
 (libraries catala.driver))

See the following module for the registration interface:

Using plugins

Plugins are dynamically loaded. The Catala compiler will be looking for them at startup within <prefix>/lib/catala/plugins (assuming that the compiler is installed into <prefix>/bin), or any other directory specified through the `--plugin-dir` command-line flag or by setting the CATALA_PLUGINS environment variable.

The plugin of your choice can then be called just like the built-in backends, using:

$ catala MyPlugin <file> [options]

Examples

python example

This trivial example registers a plugin that uses the scalc format as input. It simply calls the code of the built-in Python backend, and should be no different to using the normal Catala Python output mode.

js_of_ocaml wrapper generator example

This plugin generates a js_of_ocaml wrapper from the lcalc representation of a Catala program.

It starts by generating the OCaml module before generating the _api_web.ml one, which contains all the class types and conversion functions between the OCaml types and their corresponding JS objects. At the end the module exposes all methods in a JS lib <module_name>Lib.

See the `law_source/` directory in the OCaml french law bundle for examples of generated code.

JSON schema generator example

This plugin generates a JSON schema corresponding to a scope of a Catala program.