You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 6666 Reporter: goswin Status: acknowledged (set by @damiendoligez on 2015-01-07T18:59:36Z) Resolution: open Priority: normal Severity: feature Category: typing Monitored by:@gasche
Bug description
Sometimes one wants to re-use parts of another module without including or opening it completly. Currently this can be done by first building a new module with a reduced signature:
module M = struct type t = int let x = 1 end
module T = (struct include M end : sig type t = M.t end)
include T
I propose the following extention to the include syntax:
include <Module>.<typename>
Similary for the open syntax:
open <Module>.<typename>
And last for local open:
<Module>.<type>.(<expression>)
module M = struct type t = Foo | Bar let big = 100 end
type M.t.(match x with FOO -> 0 | Bar -> 1)
Additional information
Example:
module M = struct type t = Foo | Bar end
include M.t
let x = Foo
open M.t
let y = Bar
let to_int x = M.t.(match x with FOO -> 0 | Bar -> 1)
The text was updated successfully, but these errors were encountered:
the proposed syntax doesn't scale: what if I want to "import" more than one thing?
the proposed syntax is ad-hoc
the extra indirection in the first example (the module T) is not needed for includes, and isn't needed for opens either since Extending open #2147.
This is not to say that the syntax as it currently stands is not cumbersome, but if I understand correctly we should gain "transparent ascriptions" in a not-too-distant future, which will give us the ability to write the equivalent of the first example this way:
include (M <: sig type t end)
Given the lack of enthusiasm (or time) from other developers since this issue was first submitted, I'm closing.
Original bug ID: 6666
Reporter: goswin
Status: acknowledged (set by @damiendoligez on 2015-01-07T18:59:36Z)
Resolution: open
Priority: normal
Severity: feature
Category: typing
Monitored by: @gasche
Bug description
Sometimes one wants to re-use parts of another module without including or opening it completly. Currently this can be done by first building a new module with a reduced signature:
I propose the following extention to the include syntax:
Similary for the open syntax:
And last for local open:
Additional information
Example:
The text was updated successfully, but these errors were encountered: