coq-community / templates

Templates for configuration files and scripts useful for maintaining Coq projects [maintainers=@palmskog,@Zimmi48]
The Unlicense
12 stars 8 forks source link

Moving away from mustache #95

Open Zimmi48 opened 3 years ago

Zimmi48 commented 3 years ago

Mustache is a pretty limited template language. In particular with respect to conditionals. Here are some options for moving away from it:

Zimmi48 commented 3 years ago

I've just learned about an OCaml templating project: https://github.com/EmileTrotignon/embedded_ocaml_templates

Together with YAY, this might be enough to move away from mustache without having to learn Ruby.

erikmd commented 2 years ago

@Zimmi48 just told me about this issue; indeed, it seems a good idea to (1) use a more expressive template language than mustache, and (2) moving from shell scripts to ocaml code. But maybe in this case it could be possible to use the pyyaml package together with a Python/OCaml binding such as pyml? In this case we wouldn't need to restrict ourselves to the YAY fragment of YAML. But it may happen that the current contents of meta.yml is already fully compatible with YAY.

Zimmi48 commented 2 years ago

FTR, if YAY was not a satisfying solution and we wanted a true YAML library, we wouldn't need to go through such a route: there's also https://github.com/avsm/ocaml-yaml which provides OCaml bindings on top of the libyaml C library.

intoverflow commented 2 years ago

In my humble opinion it would be nice to keep the non-OCaml dependencies to a minimum. The Coq ecosystem is already coupled to OCaml. It may be expedient to write the tooling in Python or Ruby, but doing so adds Yet Another Language Ecosystem to the stack of things a user would need to setup in order to use the tool.

Instead of complicating our tech stack with extra language dependencies, I'd like to advocate for making the proper investments into OCaml to make it suitable for this task - especially if the primary consideration is whether or not there's a YAML parser that's up to the task.

Zimmi48 commented 2 years ago

We (Karl and I) are in agreement that it's better to depend on the OCaml ecosystem because it will make it easier for Coq users to contribute than if we were to use, say Ruby. So this is what we plan for the v2 of the templates.

Regarding the question of a YAML parser, there are actually two options: the YAY (full OCaml) parser and the ocaml-yaml library (both were mentioned above). So we should be fine.

erikmd commented 2 years ago

Just in case FYI (this is not an objection, I'm very fine with the latest comment by @Zimmi48):

there would also be the solution of using a bash script + yq, see e.g.:

https://stackoverflow.com/questions/71393380/fetch-variables-values-from-yml-and-pass-to-shell-script/71397858#71397858

Pros: lighter, no language barrier such as that of ruby Cons: more fragile, and bash is not statically type-checked :)