ocaml-mlx / ocaml-mlx/mlx

Support OCaml 5.2+ functor parameter syntax

Open
#34 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
OCaml
Stars
148
Forks
7
Avg merge
2d 1h
Merged PRs (30d)
6

Description

Versions

  • mlx: 0.11
  • OCaml: 5.5.0
  • ocamlformat-mlx: 0.28.1.2

Problem

mlx-pp rejects the newer functor type syntax accepted by OCaml 5.2+ and emitted by ocamlformat-mlx when formatting for current OCaml versions.

Reproduction

mlx-pp -print-ml <<'MLX'
module type T = sig
  type t
end

module Fresh : (X : T) -> sig
  type t
end =
functor (X : T) -> struct
  type t = X.t
end
MLX

Actual result:

File "*stdin*", line 5, characters 18-19:
Error: Syntax error: ')' expected
File "*stdin*", line 5, characters 15-16:
  This '(' might be unmatched

The same declaration is accepted by the OCaml 5.5 toplevel.

Context

This appeared while converting a Reason functor to MLX. ocamlformat-mlx produced the syntax above, but the Dune MLX preprocessor could not parse the formatted file.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided reproduction through the mlx-pp preprocessor and tracing its parser handling of module and functor type declarations. Inspect the parser entry points involved in the reported syntax error; done means the OCaml 5.2+ declaration is accepted and the Dune MLX preprocessing path has a regression test for it.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.