What does HackerNews think of mlang?

Compiler for the M language, used to compute the income tax of French taxpayers

Language: OCaml

Catala still produces plaintext legal documents at the end of the day but can be seen as a markup language for those documents. But because that markup language is a whole lot more precise than the legal text itself, it can be a bit more versatile.

Examples of how this could be useful:

- Reducing the overhead for maintaining a list of semantic translations of that legal code into other languages. Of course the official language is the only one that is "legal" but the other translations should be close enough to effectively express the nuance provided the language outputs are maintained by people who can actually speak those languages.

- Producing machine executable proof or simulation code. This could be used for "fuzzing" the legal code to identify loopholes or unintended outcomes so that legislators can then propose improved terms to avoid those issues. This is by no means "making code law" but it provides an additional tool for understanding the law and how the many different parts of the legal code interact with each other.

- Adding on to the previous example, sim code could be integrated into complex models for simulating the impact of legal changes on the economy at large or specific segments.

- Finance related code can be used to generate a tool or API for validating tax, accounting, and compliance documents (as a first pass to catch errors early and reduce overhead) as well as to even prepare some of those documents. These tools often already exist but they are one or more steps removed from the actual legal definition which increases the risk of error as well as the overhead of maintaining them (which can potentially encourage rent seeking behavior by commercial providers of these tools).

France actually is already doing this to a reasonable degree albeit the "codified" version is based on the law rather than the codified version producing plaintext law. The DGFiP [1] maintains a gitlab organisation [2] that includes both Catala and MLang [3] representations of different parts of the french legal code for exactly these purposes.

1. https://fr.wikipedia.org/wiki/Direction_g%C3%A9n%C3%A9rale_d...

2. https://gitlab.adullact.net/dgfip

3. https://github.com/MLanguage/mlang

french tax code has a semi-official DSL syntax

https://github.com/MLanguage/mlang

just adopt theirs, add a message layer, and call it done

France has an open source implementation of their tax code [0]. The paper [1] gives an overview of the implementation language, mlang.

[0] https://github.com/MLanguage/mlang [1] https://arxiv.org/abs/2011.07966

The french initiative started in 2013 is still alive (last commit a few days ago), and passes the gov test suite (they keep in touch with our version of the IRS): https://github.com/openfisca/openfisca-france

The way we got this is interestingly twisted.

French citizens requested the software used by the administration, and they managed to get it!

But, it was written in Mlang, a proprietary language created by the french administration in the 90: https://github.com/MLanguage/mlang.

Someone then decided to create an OCaml compiler that takes mlang and emits python: https://arxiv.org/abs/2011.07966

As a result, we got Open Fisca. I now think there are other techs in the mix...

A slide of the story: https://www.slideshare.net/Etalab/opening-up-the-french-tax-...

But I believe it should be mandatory for the state to provide the source of every softwares they use internally to manage our lives. Also a test suite to allow any citizen to validate their own effort to comply with the law.

Just like laws should be published as diff of the previous laws, in a VCS repo.

There have been attempts by the French and Dutch governments to codify parts of tax law as a trial of sorts, check out M for one https://github.com/MLanguage/mlang

Nevertheless, such efforts cover minimal portions already very clearly defined and debated. As another commenter replied, reforms are rarely undertaken for various reasons. One great issue with tax law is also that whatever code you may write is not necessarily guaranteed to be 'better' (fairness, revenue collected, lack of loopholes and edge cases, completeness, correctness... pick your metric) simply because it's code. That's what I thought too; but no longer.

--> https://github.com/MLanguage/mlang

"Compiler for the M language, used to compute the income tax of French taxpayers"

You might be interested in the French example, if you don’t know already. They designed the Mlang DSL for tax calculation, and released a bunch of things on GitHub.

Here is the compiler: https://hal.inria.fr/hal-03002266v3/document

https://github.com/MLanguage/mlang

They’ve also open sourced an official calculator, along with web APIs: https://github.com/openfisca/openfisca-france