# \[ANN\] .mlx syntax dialect

**URL:** <https://discuss.ocaml.org/t/ann-mlx-syntax-dialect/15035>\
**Category:** Community\
**Tags:** mlx, announce\
**Created:** [July 27, 2024, 7:06am UTC](https://discuss.ocaml.org/t/ann-mlx-syntax-dialect/15035 "2024-07-27T07:06:33Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![andreypopp](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/andreypopp/32/97_2.png) [@andreypopp](https://discuss.ocaml.org/u/andreypopp)\
**Post date:** [July 27, 2024, 7:06am UTC](https://discuss.ocaml.org/t/ann-mlx-syntax-dialect/15035/1 "2024-07-27T07:06:33Z")

</div>

Dear OCaml community,

it is my pleasure to announce a release of [.mlx](https://github.com/ocaml-mlx/mlx) dialect.

The .mlx dialect extends OCaml syntax with JSX expression construct, following the example of JSX in JavaScript/ReasonML. A brief snippet:

```ocaml
let page ?(encoding="utf8") ~title ~content =
  <html>
    <head>
      <meta charset=encoding />
      <title>title</title>
    </head>
    <body>
      content
    </body>
  </html>

let _ = <page title="Hello" content="World" />

```

The main use case is to make it easier to describe user interfaces with OCaml, which can range from generating HTML ([example with Dream](https://github.com/aantron/dream/blob/dc805cb46fd99001bc828cddb9de053a3dc464eb/example/w-mlx/README.md)) to describing interactive UIs with ReasonReact ([example](https://github.com/andreypopp/melange-mlx-template/blob/main/src/ReactApp.mlx)).

### Installation and usage

Install the packages from opam:

```sh
opam install mlx ocamlmerlin-mlx

```

Then configure dune to use the `mlx` preprocessor:

```lisp
(dialect
 (name mlx)
 (implementation
  (extension mlx)
  (merlin_reader mlx)
  (preprocess
   (run mlx-pp %{input-file}))))

```

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](https://github.com/ocaml-mlx/ocaml_mlx.nvim), which does that bit of a configuration and provides highlighting for `.mlx` files based on a tree-sitter parser.

---

_[View the full topic](https://discuss.ocaml.org/t/ann-mlx-syntax-dialect/15035)._
