package ocamlmerlin-mlx

  1. Overview
  2. Docs
Merlin support for MLX OCaml dialect

Install

Dune Dependency

Authors

Maintainers

Sources

0.9.tar.gz
md5=c413c013d6c3a905e9b77cc2f65413cf
sha512=b16bcbb1e168fbc4d31b3f72f3e4d9b8d161988724a85c256f6e3f9795868fe77934ccead62b843f360da67a028f6bd484f2f4c5216d51ac9dc372439b0fc717

Description

Published: 23 Jun 2024

README

mlx

An OCaml syntax dialect which adds JSX expressions to the language.

let header ~children () = 
  <header>
    <h1>title</h1>
  </header>

let page =
  <html>
    <body>
      <header>"Hello, world!"</header>
      <div>
        "Some content goes here"
      </div>
    </body>
  </html>

This code is transformed into the following OCaml code:

let header ~children () =
  header () ~children:[ h1 () ~children:[ title ] [@JSX]; ] [@JSX]

let page =
  html () ~children:[
    body () ~children:[
      header () ~children:[ "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

Currently for editor integration an unreleased version of ocaml-lsp-server is needed (along with its depenedencies, jsonrpc and lsp).

Use the following commands to install the necessary packages:

opam pin add jsonrpc.dev --dev
opam pin add lsp.dev --dev
opam pin add ocaml-lsp-server.dev --dev
opam install mlx ocamlmerlin-mlx

To 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}))))

Dependencies (5)

  1. cppo
  2. merlin-lib
  3. dune >= "3.15"
  4. ppxlib >= "0.32.1"
  5. ocaml >= "4.14.0"

Dev Dependencies (3)

  1. odoc with-doc
  2. menhir = "20201216" & with-dev-setup
  3. csexp with-dev-setup

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.