The main use case is to make it easier to describe user interfaces with OCaml, which can range from generating HTML (example with Dream) to describing interactive UIs with ReasonReact (example).
Now files with .mlx extension will be treated as OCaml modules.
The merlin/ocamllsp users will get roughly the same level of support for .mlx syntax as they get for .ml but some additional text editor/IDE configuration is needed to associate .mlx files with merlin/ocamllsp.
For neovim users there’s a plugin ocaml-mlx/ocaml_mlx.nvim, which does that bit of a configuration and provides highlighting for .mlx files based on a tree-sitter parser.
Looks great, that’s exactly what I was looking for. I’d love to use OCaml with Melange to write react apps but really don’t want to resort to Reason for this. Hopefully not too off topic: Any idea if the reason-react-ppx is going to work with the original OCaml-syntax so I can build the whole app in OCaml?
Unfortunately there’s no good answer to that, the alternatives we’ve considered for JSX children syntax were:
Implement it as it is now — as a list of simple expressions
Use {..} brackets like you’ve suggested
Use ; delimiter for a list of expressions
The 3. was ruled out as being to noisy. The 2. is also a good proposal but choice was made in favour of 1. partly because of simplicity.
I agree, it can seen confusing at first but the rule is simple — if that’a a non simple expressions (like application), then you wrap it with (..), as in normal .ml syntax.
A small follow up announcement, the new package ocamlformat-mlx has been released on opam. It’s a fork of ocamlformat with support for formatting .mlx syntax.