Skip to content
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

Feature: shorter syntax to include parts from another module #6666

Closed
vicuna opened this issue Nov 19, 2014 · 1 comment
Closed

Feature: shorter syntax to include parts from another module #6666

vicuna opened this issue Nov 19, 2014 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Nov 19, 2014

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)
@vicuna vicuna added the typing label Mar 14, 2019
@trefis
Copy link
Contributor

trefis commented Mar 15, 2019

I'm not convinced by this:

  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants