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

Generalized polymorphic #install_printer #5958

Closed
vicuna opened this issue Mar 23, 2013 · 5 comments
Closed

Generalized polymorphic #install_printer #5958

vicuna opened this issue Mar 23, 2013 · 5 comments

Comments

@vicuna
Copy link

vicuna commented Mar 23, 2013

Original bug ID: 5958
Reporter: @ppedrot
Assigned to: @chambart
Status: closed (set by @xavierleroy on 2017-02-16T14:14:08Z)
Resolution: fixed
Priority: normal
Severity: feature
Fixed in version: 4.03.0+dev / +beta1
Category: runtime system and C interface
Tags: patch
Related to: #6908
Monitored by: @bobzhang

Bug description

It would be nice to have the toplevel #install_printer recognizing polymorphic printing functions of the following form:

(Formatter.t -> 'a -> unit) -> (Formatter.t -> 'a t -> unit)
(Formatter.t -> 'a -> unit) -> (Formatter.t -> 'b -> unit) -> (Formatter.t -> ('a, 'b) t -> unit)

(... and so forth for any number of parameters)

The additional function arguments would be the current printer specialized at their respective type arguments.

This would permit to reuse the current printer for polymorphic data structures. I think it is possible to do so hacking the compiler-libs, but I did not manage to figure how to do it properly. So having it built-in would be more user-friendly, in particular for the debugger.

File attachments

@vicuna
Copy link
Author

vicuna commented Jul 23, 2013

Comment author: hnrgrgr

The attached patches are work in progress and need to be tested and improved.

The first patch allows the generic printer (in 'genprintval') to be extended with parameterised printers. The second one extends the #install_printer directive accordingly.

@vicuna
Copy link
Author

vicuna commented Jun 20, 2014

Comment author: @chambart

I updated the patches for lastest trunk and added a fix to prevent adding generic printers with old-style type ('a -> unit instead of formatter -> 'a -> unit)

@vicuna
Copy link
Author

vicuna commented Nov 23, 2014

Comment author: @ppedrot

Is there any hope to see those patches merged?

@vicuna
Copy link
Author

vicuna commented Dec 6, 2014

Comment author: @gasche

Merged in trunk, thanks!

@vicuna
Copy link
Author

vicuna commented Jun 18, 2015

Comment author: @alainfrisch

Apprently, this got cherry-picked in 4.02, with unintended consequences on 4.02.2 (see #6908).

Refs:

commit in trunk: 15632
commit in 4.02: 15699

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