ocaml-doc / doc-ock

(DEPRECATED) Documentation generation for OCaml
ISC License
15 stars 5 forks source link

Extension constructor identifiers aren't children of their type #23

Closed dsheets closed 9 years ago

dsheets commented 9 years ago

Normal variant constructor identifiers are children of their type.

lpw25 commented 9 years ago

I think that this is as it should be. Extensions can be added to types from other modules. For example,

module M : sig
  type t = ..
end

module N : sig
  type M.t += C
end

You can't refer to C as N.t.C because N.t does not exist (and it does not specify which t you mean). You can't refer to C as M.t.C because the type is open so their could be many Cs in t and you don't know where they might be.

dsheets commented 9 years ago

Right, but being a child of the signature isn't correct, either. For instance:

module M : sig
type t = ..
type u = ..

type t += C
type u += C
end

These constructors are distinct but don't have unique paths. What is required is the ability to refer to one path in the context of another. For your example, C is something like N#M.t.C or N~M.t.C.

lpw25 commented 9 years ago

Yes, but that example no longer works on trunk (for almost this exact reason), so by 4.03 this will not be a problem.

dsheets commented 9 years ago

Oh? I thought

module M : sig
  type t = ..
  type t += C
end

type M.t += C

and

type t = ..
type t += C
type t += C

were being disallowed.

lpw25 commented 9 years ago

No it is having multiple extensions with the same name in the same module (regardless of which type they extend) that is being disallowed. This means your original example, and your second new example, but not your first new example.

Note that it is not generally possible to disallow your second new example and allow your original example, because it is not in general possible to know that two types are distinct.