-
Notifications
You must be signed in to change notification settings - Fork 100
Module type alias #703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module type alias #703
Conversation
- Don't expand module types if they're just a `Path` to another one - If a module type is a `Path` to another, add in a `AliasModuleType` constructor, which indicates that URLs should point to the aliased module type rather than the original
7838de3
to
07faa71
Compare
07faa71
to
35c51bf
Compare
1d63c83
to
564d13a
Compare
564d13a
to
c51d0a7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Late review
@@ -314,7 +314,7 @@ and module_type : Env.t -> ModuleType.t -> ModuleType.t = | |||
let expr = | |||
match m.expr with | |||
| None -> None | |||
| Some e -> Some (module_type_expr env sg_id e) | |||
| Some e -> Some (module_type_expr env sg_id ~expand_paths:false e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to disable expansion here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only time we actually want to consider skipping the expansion of paths is when handling a ModuleType
signature item - we never want to for for Module
items, and we never want to when recursing.
@@ -334,6 +332,8 @@ and is_resolved_module_type_hidden : Resolved.module_type -> bool = function | |||
| `ModuleType (p, _) -> is_resolved_parent_hidden ~weak_canonical_test:false p | |||
| `SubstT (p1, p2) -> | |||
is_resolved_module_type_hidden p1 || is_resolved_module_type_hidden p2 | |||
| `AliasModuleType (p1, p2) -> | |||
is_resolved_module_type_hidden p1 || is_resolved_module_type_hidden p2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be just is_resolved_module_type_hidden p1
? There is a few conditions similar to "if p2 is hidden then use p1 else use p2", so does it matter if p2
is hidden here ?
@@ -24,6 +23,7 @@ module rec Resolved : sig | |||
| `Identifier of Identifier.ModuleType.t | |||
| `ModuleType of parent * ModuleTypeName.t | |||
| `SubstT of module_type * module_type | |||
| `AliasModuleType of module_type * module_type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment saying which is which ?
(i :> Id.Signature.t) = id | ||
in | ||
let expansion_needed = self_canonical || hidden_alias in | ||
if expansion_needed then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expansion_needed
code only uses generic types, perhaps it can be shared with the module case ?
sg.items | ||
|
||
(* Really cut-down reference lookup! *) | ||
let rec handle_ref : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A simpler implementation might be to open the signature into an empty environment and use the env instead of implementing lookups.
CHANGES: Breaking changes - Remove odoc-parser into a separate repository (@jonludlam, ocaml/odoc#700) Additions - OCaml 4.13 support (@Octachron, ocaml/odoc#687, ocaml/odoc#689) - Better errors/warnings (@Julow, ocaml/odoc#692, ocaml/odoc#717, ocaml/odoc#720, ocaml/odoc#732) - ModuleType 'Alias' support (@jonludlam, ocaml/odoc#703) - Improved test suite (@lubega-simon, ocaml/odoc#697) - Improved documentation (@lubega-simon, @jonludlam, ocaml/odoc#702, ocaml/odoc#733) - Strengthen module types (@jonludlam, ocaml/odoc#731) Bugs fixed - `uwt` now can be documented (@jonludlam, ocaml/odoc#708) - Fix resolution involving deeply nested substitutions (@jonludlam, ocaml/odoc#727) - Fix off-by-one error in error reporting (@asavahista, ocaml/odoc#736)
Implement module type aliases.
When there is a module type that is simply an alias to another module type then we don't expand it.