include functor support for OxCaml - #1452
Conversation
18499bf to
ca9079a
Compare
ca9079a to
a6c9652
Compare
art-w
left a comment
There was a problem hiding this comment.
Thanks a lot, this looks great! I only have minor feedback but nothing blocking :)
| (** This is a Module where the type is named and then included. *) | ||
| module type Make = (_ : sig type t end) -> sig type included end | ||
| type t | ||
| include functor Make |
There was a problem hiding this comment.
Out of curiosity, can we test the behavior with (** @inline *)?
|
I think there's a chunk of logic missing from this PR. At the moment, all it does AFAICT is get the expansion of the functor and splice it into the expansion of the include. While this works for simple examples, it's not sufficient for more involved cases. As a simple example, consider this: module F ( I : sig type t end ) = struct
type myt = I.t
end
module M = struct
type t = float
include functor F
endRunning this through module F : functor (I : sig type t end) -> sig type myt = I.t end
module M : sig type t = float type myt = float endIf we just simply get the signature of the functor body and splice it in, we end up something more like: ...
module M : sig
type t = float
type myt = I.t
endand obviously that I suspect the most straightforward implementation of this would be to do exactly what the docs suggest it does internally. Treat it more like: module M = struct
module __DUMMY__ = struct
type t = float
end
include __DUMMY__
include F(__DUMMY__)
endWe can ensure that the dummy module is hidden, meaning that the include will just inline the contents, |
78e4383 to
e8b5ba1
Compare
Signed-off-by: Marek Kubica <marek@tarides.com>
Signed-off-by: Marek Kubica <marek@tarides.com>
Signed-off-by: Marek Kubica <marek@tarides.com>
e54c667 to
1dbd45c
Compare
1dbd45c to
5997c73
Compare
5997c73 to
ac92802
Compare
|
I've now implemented @jonludlam's proposal of compiling down the include functor to basically a The way it works is by parsing the However there's one outstanding issue: while the items coming from the functor expansions contain the right path (e.g. What I could imagine would be best if I could hide the generated modules but also tell the cross-linker that I want the item to be cross-referenced to the ("include") functor, not the generated module. Is there a way to tell odoc to "redirect" paths? |
|
Odoc has a mechanism to specify a substitution via |
This PR is a follow up to #1368 and adds support for
include functorwhere it now displays that the items were included via the functor.