package mlx
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=bea6b7e57deb13a1cc20af3fe9101b90b77d3e886097c6d44dd63eb96f5aaceb
sha512=a73d0b22f99709be9f0d2753372b43198a4e064a318f22ea68f37e965baa7a0b1b43f43b15e043f556c8d15e5475e31eb039472aa33aeceeee76ec68eca3e7fb
Description
Published: 28 Dec 2025
README
mlx
An OCaml syntax dialect which adds JSX expressions to the language.
let header ~title () =
<header>
<h1>title</h1>
</header>
let page =
<html>
<body>
<header title="Hello, world!" />
<div>
"Some content goes here"
</div>
</body>
</html>This code is transformed into the following OCaml code:
let header ~title () =
header () ~children:[ h1 () ~children:[ title ] [@JSX]; ] [@JSX]
let page =
html () ~children:[
body () ~children:[
header () ~title:"Hello, world!" [@JSX];
div () ~children:[ "Some content goes here" ] [@JSX];
] [@JSX];
] [@JSX]It is expected to use mlx-pp preprocessor with either a runtime lib which provides the implementation of such functions or a ppx which which further transforms [@JSX] attributes into the desired output.
Installation & Usage
Use the following commands to install the necessary packages:
opam install mlx ocamlmerlin-mlxTo make dune consider .mlx files as OCaml files you need to configure an mlx dialect, put this in your dune-project file:
(dialect
(name mlx)
(implementation
(extension mlx)
(merlin_reader mlx)
(preprocess
(run mlx-pp %{input-file}))))Editor Support
VS Code
For VSCode and its forks (Cursor, Windsurf, etc.), install the Official OCaml Platform extension (version 2.0.0 or higher). It supports mlx syntax highlighting and all LSP features on par with .ml files.
Neovim
For Neovim users, install plugin: https://github.com/ocaml-mlx/ocaml_mlx.nvim
Useful Links
- Example with Dream web framework: https://github.com/aantron/dream/pull/330
- Template ReasonReact project: https://github.com/andreypopp/melange-mlx-template
- mlx announcement on OCaml Discourse: https://discuss.ocaml.org/t/ann-mlx-syntax-dialect/15035
Dev Dependencies (4)
-
odoc
with-doc -
ocaml-lsp-server
with-dev-setup -
ocamlformat
with-dev-setup -
menhir
= "20201216" & with-dev-setup
Used by (3)
- brisk-reconciler
-
html_of_jsx
>= "0.0.5" - react-rules-of-hooks-ppx
Conflicts
None