Skip to content

Ocaml 5.5 compat#1406

Merged
jonludlam merged 10 commits into
ocaml:masterfrom
panglesd:ocaml-5.5-compat
Apr 17, 2026
Merged

Ocaml 5.5 compat#1406
jonludlam merged 10 commits into
ocaml:masterfrom
panglesd:ocaml-5.5-compat

Conversation

@panglesd
Copy link
Copy Markdown
Collaborator

@panglesd panglesd commented Mar 25, 2026

Support for 5.5 with:

  • Support for external types, displayed as abstract types
  • Support for module arrows.

The second one is trickier. In this PR, at least:

  • The type is written
  • There is no warning about missing elements from the environment.

However, the path referencing the module argument appear as unresolved links: underlined in red, suggesting an error...

The state of the PR is draft because it needs to be cleaned up and improved, but I already open it in case someone wants to try odoc on OCaml 5.5.

🤖 Generated with @xvw

@panglesd panglesd mentioned this pull request Mar 25, 2026
Comment thread odoc.opam Outdated
Comment thread odoc-parser.opam Outdated
depends: [
"dune" {>= "3.21"}
"ocaml" {>= "4.08.0" & < "5.5"}
"ocaml" {>= "4.08.0" & <= "5.5.1"}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one too!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually thinking about it, why do we have an upper bound on odoc-parser? I can understand with odoc where every ocaml release breaks it, but the parser ought to be way less brittle.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, there is no reason to have this "minor release" upper bound!

@panglesd panglesd force-pushed the ocaml-5.5-compat branch 4 times, most recently from 4415c76 to 54a3814 Compare April 8, 2026 15:53
panglesd added a commit to panglesd/odoc that referenced this pull request Apr 8, 2026
@panglesd panglesd marked this pull request as ready for review April 8, 2026 16:07
@panglesd
Copy link
Copy Markdown
Collaborator Author

panglesd commented Apr 8, 2026

I'd still like to clean the history, but the PR is ready for review.


val g' : (module M : Y) -> int

val g'' : (module Y) -> int
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably also add a test for polymorphic parameters:

val map2: ('a. 'a -> 'a) -> 'a * 'b -> 'a * 'b

after a quick look, I have the impression that the current document generation code is missing parentheses.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'll add that today.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cherry-picked @art-w's 0752cc5 which fixed exactly that (thanks!).

@art-w I did not include the Oxcaml test since it is not part of "5.5 support". Whichever is merged last, #1404 or this one, will have to rebase!

panglesd added a commit to panglesd/odoc that referenced this pull request Apr 13, 2026
panglesd added a commit to panglesd/odoc that referenced this pull request Apr 13, 2026
@panglesd
Copy link
Copy Markdown
Collaborator Author

I'd still like to clean the history

I rebased and cleaned the history. (And addressed ochtachron's comment)

Jon Ludlam's Agent and others added 8 commits April 15, 2026 11:20
- pack_cstrs renamed to pack_constraints in Types.package
- tpt_cstrs renamed to tpt_constraints in Typedtree.package_type
- typ_cstrs renamed to typ_constraints in Typedtree.type_declaration
- New Type_external/Ttype_external constructors for external types
- New Tfunctor/Ttyp_functor constructors in type_desc/core_type_desc
- New Local_opaque_item constructor in Shape.Uid
- Typemod.path_of_module moved to Typedtree.path_of_module

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The way it works is not ideal: we create a synthetic parent id for each module
argument (as they can be introduced multiple times with the same name in the
same type expression). This id is hidden and we don't render links to hidden
ids.

This is slightly bad because:
- The appearance of unresolved links suggest an error when there is no.
- There is no way to distinguish module args from normal modules

But let's say it is a good first step!

Co-authored-by: xvw <xavier.vdw@gmail.com>
Co-authored-by: Kate <kit-ty-kate@exn.st>
@panglesd
Copy link
Copy Markdown
Collaborator Author

Rebased since the merge of #1404

Copy link
Copy Markdown
Contributor

@xvw xvw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what it's worth, and judging by the output results!

@Octachron
Copy link
Copy Markdown
Member

On the subject of the module argument, I was wondering if it would not better to link M.t in (module M:T) -> M.t
to the t component of the module type since at least for now the module type of a module argument is always a named module.

Nevertheless, I agree that this can be improved later.

@panglesd
Copy link
Copy Markdown
Collaborator Author

On the subject of the module argument, I was wondering if it would not better to link M.t in (module M:T) -> M.t
to the t component of the module type since at least for now the module type of a module argument is always a named module.

Would you link the same way when the type is replaced?

module type S =  sig type t = float end

val f : (module M : S with type t = int) -> M.t

I would find it misleading! The way to improve I can think of are too involved for this initial support...

@Octachron
Copy link
Copy Markdown
Member

Your example is a type error, thus I am not sure how illustrative it is.
The constraints can only refine an abstract type:

module type S = sig type t end
val f : (module M : S with type t = int) -> M.t

in which case is not that clear what is the best option between linking to M.t or int, but following the intent
of the author that wrote M.t rather than t does not sound that bad.

Anyway, I agree that this is probably best left for further refinement.

@jonludlam
Copy link
Copy Markdown
Member

Looks good! I came across some test failures when I was looking through it though, so I've fixed them (very minor). As soon as CI shows green we'll merge!

@jonludlam jonludlam merged commit 4fa086b into ocaml:master Apr 17, 2026
11 checks passed
jonludlam pushed a commit that referenced this pull request Apr 17, 2026
jonludlam added a commit to jonludlam/opam-repository that referenced this pull request May 1, 2026
CHANGES:

- Allow persistent latex macros in HTML/KaTeX backend (@dlesbre, ocaml/odoc#1391)
- `markdown-generate` command now accepts multiple `.odocl` files in a single
  invocation, eliminating the need for shell scripting (@davesnx, ocaml/odoc#1387)
- Support for OxCaml (@lukemaurer, @art-w, ocaml/odoc#1399)
- OCaml 5.5.0 support (@panglesd, @xvw, ocaml/odoc#1406)

- Fix compile-time crashing bugs ocaml/odoc#930 and ocaml/odoc#1385 (@jonludlam, ocaml/odoc#1400)
- Markdown backend assumes ocaml as langId on declarations
- Markdown backend collects all code snippets and render a single code block with comments, rather than split the variants/records per constructor/field
- Fix URL remapping for page references (@jonludlam, ocaml/odoc#1395)
- Fix ocaml/odoc#1396, which broke incrememntal builds (@jonludlam, ocaml/odoc#1402)
- Ensure all warnings turn into errors with --warn-error (@jonludlam, ocaml/odoc#1402)
- Fix missing parentheses for polymorphic arguments (@art-w, ocaml/odoc#1404)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants