Skip to content

OxCaml: Support for kind annotations#1410

Merged
jonludlam merged 3 commits into
ocaml:masterfrom
art-w:oxcaml-layout
May 21, 2026
Merged

OxCaml: Support for kind annotations#1410
jonludlam merged 3 commits into
ocaml:masterfrom
art-w:oxcaml-layout

Conversation

@art-w
Copy link
Copy Markdown
Collaborator

@art-w art-w commented Apr 14, 2026

Builds on top of #1404 (which adds the oxcaml test file)

This PR adds support for OxCaml kind annotations :)

@art-w art-w changed the title Oxcaml layout OxCaml: Support for kind annotations Apr 14, 2026
("recent.mli", Min "5.4");
("labels.mli", Min "4.09");
("recent_impl.ml", Min "4.09");
("recent_impl.ml", MinNotOxCaml "4.09");
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.

recent_impl.ml is the only .ml file currently tested, and it uses simple type t = A which in OxCaml now renders as type t : immediate = A (which is correct, but not compatible with the OCaml output). I tried to "complexify" the type definition, but then you either get immutable_data or mutable_data instead so that doesn't help! :P

(This doesn't seem to be an issue for .mli testing, because OxCaml doesn't try to infer more precise kinds than the ones specified)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That seems fine to me. OxCaml not being run on this specific test seems fine. Adding the variant MinNotOxCaml is fine.

Just to confirm I understand correctly:

type t = A

will be loaded as different values in odoc, depending on whether they are in an ml or mli file:

  • In an ml file, some layout is inferred for t, from the definition, and stored in the cmt
  • In an mli file, nothing is inferred and the Default annotation is loaded from the cmi.

This seems strange, and will discourage the use of ml without mli, since it will be impossible to have a type without an annotation!
But if it comes from the cmti, I'm not sure we should do anything about that.

@art-w art-w marked this pull request as draft April 14, 2026 12:48
@art-w art-w force-pushed the oxcaml-layout branch 3 times, most recently from 50e0a0b to d0a2d4e Compare April 15, 2026 15:39
@art-w art-w marked this pull request as ready for review April 15, 2026 15:40
Copy link
Copy Markdown
Collaborator

@panglesd panglesd left a comment

Choose a reason for hiding this comment

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

Looks good to me!

The only improvements I see is to have test the kind products (eg, bit32 & float64). In particular, do we need to use parentheses for thing like (bit32 mod portable) & (float64 mod contended)?

I am also not sure what Pjk_kind_of represents, and whether it is tested or not...

Comment thread src/document/generator.ml Outdated
Comment thread src/document/generator.ml Outdated
@art-w art-w force-pushed the oxcaml-layout branch 2 times, most recently from 91731c7 to d23585b Compare May 20, 2026 09:43
@art-w
Copy link
Copy Markdown
Collaborator Author

art-w commented May 20, 2026

Thanks everyone! I've rebased and updated for OxCaml minus31, with some new tests and fixes following the reviews :)

@panglesd > The Pjk_kind_of is a new syntax which isn't supported atm (example at https://github.com/oxcaml/oxcaml/blob/main/testsuite/tests/parsetree/source_jane_street.ml#L1375 ), so I can't easily test it. While upgrading to minus31, I also noticed a new syntax to declare a kind abbreviation kind_ my_abbrev = value mod etc to be used later type t : my_abbrev (I added a test which shows the type declaration renders correctly, but that the kind_ declaration is missing and that there's no link from the abbreviation to its declaration => I would prefer to follow-up on this in a separate PR if there's no objection)

@jonludlam
Copy link
Copy Markdown
Member

jonludlam commented May 20, 2026

mdx tests failed. I'm very doubtful they provide any value any more - they're very old and have largely been superseded by newer tests. I'd be happy for them to be removed.

Copy link
Copy Markdown
Collaborator

@panglesd panglesd left a comment

Choose a reason for hiding this comment

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

Looks good to me!

I'm happy to have the kind abbrev in another PR.

Kinds do not have any "format breaks", but this can also be fixed in another PR (especially, I don't know if it is a big deal, how often are there so many kinds it's better to break, but I hope not too often)

I left a nitpick on an unimplemented feature.

Comment thread src/document/generator.ml Outdated
@panglesd
Copy link
Copy Markdown
Collaborator

panglesd commented May 20, 2026

And I agree with the removal of mdx tests. I've never had a bug found by an mdx test not covered by a cram test. It could be in this PR or another.

@art-w art-w mentioned this pull request May 21, 2026
@art-w
Copy link
Copy Markdown
Collaborator Author

art-w commented May 21, 2026

I've fixed the mdx tests here, and submitted #1437 to get rid of them in the future :)

@jonludlam
Copy link
Copy Markdown
Member

Thanks!

@jonludlam jonludlam merged commit d8be4e2 into ocaml:master May 21, 2026
10 of 11 checks passed
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.

4 participants