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

Printing of type aliases in signatures could be improved (with nonrec) #7458

Closed
vicuna opened this issue Jan 12, 2017 · 5 comments
Closed

Printing of type aliases in signatures could be improved (with nonrec) #7458

vicuna opened this issue Jan 12, 2017 · 5 comments

Comments

@vicuna
Copy link

vicuna commented Jan 12, 2017

Original bug ID: 7458
Reporter: @yallop
Assigned to: @garrigue
Status: assigned (set by @damiendoligez on 2017-02-23T16:03:12Z)
Resolution: open
Priority: normal
Severity: feature
Target version: later
Category: typing
Related to: #4791 #6634
Monitored by: @gasche @hcarty

Bug description

Type aliases declared with nonrec are printed with nonrec, as expected:

 # module type S = sig type t module M : sig type nonrec t = t end end;;
 module type S = sig type t module M : sig type nonrec t = t end end

but type aliases resulting from substitution are printed incorrectly:

 # module type S = sig type t module M : sig type t end with type t = t end;;
 module type S = sig type t module M : sig type t = t end end
@vicuna
Copy link
Author

vicuna commented Jan 17, 2017

Comment author: @garrigue

This is just a fresh instance of the "unprintable signature bug", with the variant that here, there is a way to print it correctly.
Unfortunately, this is not so easy in general.
For instance, consider:

module type S = sig type t module M : sig type u = U of v * t and t and v = u end with type t = t end

In order to print this type correctly, one would have to reorder the definitions, to remove t from its recursive group, and have it come first. This is doable, but not completely trivial. And there is the question of whether we want to do that always, or only when needed (requires some detection code), i.e. avoid to change the apparence of the signature when this is not needed.

So my feeling is that it is doable (move each instantiated definition just before its recursion group, and add a nonrec keyword), but requires a bit of code to do it, and more code if we want to be conservative.

@github-actions
Copy link

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

@github-actions github-actions bot added the Stale label Aug 24, 2020
@shindere
Copy link
Contributor

shindere commented Aug 25, 2020 via email

@yallop
Copy link
Member

yallop commented Aug 25, 2020

Local substitutions should make this easier. For example, @garrigue's example now has a straightforward solution:

module type S = sig
  type t
  module M : sig
    type t' := t
    type u = U of v * t
     and t = t'
     and v = u
  end
end

as does my original example:

module type S = sig
   type t
   module M : sig
     type t' := t
     type t = t'
   end
end

@trefis
Copy link
Contributor

trefis commented Aug 25, 2020

#6634 seems to be the place where the discussion is happening; so I'm closing this.

@trefis trefis closed this as completed Aug 25, 2020
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

5 participants