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

Automatically install printers marked with [@@ocaml.toplevel_printer] #269

Merged
merged 2 commits into from
Jan 24, 2019

Conversation

ghost
Copy link

@ghost ghost commented Jan 15, 2019

This PR makes utop automatically install as printer all functions marked with [@@ocaml.toplevel_printer] in mli files. This gives a very simple way for users to define new toplevel printers.

Scan newly loaded cmi files for values marked with the
[@@ocaml.toplevel_printer] attribute and automatically install them as
toplevel printers.
@ghost ghost mentioned this pull request Jan 15, 2019
@avsm
Copy link
Collaborator

avsm commented Jan 18, 2019

This is a good idea! Still failing on 4.03 with

- File "src/lib/uTop_main.ml", line 615, characters 22-51:
- Error: Unbound module Env.Persistent_signature

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
@ghost ghost force-pushed the printers branch from 5aa8695 to 328d491 Compare January 21, 2019 19:20
@ghost
Copy link
Author

ghost commented Jan 21, 2019

Oops, indeed I got the condition wrong. It's fixed now.

@pmetzger
Copy link
Member

pmetzger commented Jan 24, 2019

Looks like all checks are successful, so I'll merge this. That said, shouldn't it be documented?

@pmetzger pmetzger merged commit 4e9b9d1 into master Jan 24, 2019
avsm added a commit to avsm/opam-repository that referenced this pull request Jan 31, 2019
CHANGES:

The new feature in this release is to automatically install
printers marked with `[@@ocaml.toplevel_printer]` (ocaml-community/utop#269 @diml).
Adding this annotation to your libraries will remove the need
to have a separate `top` package to install the printers.

For example, in the [uri](https://github.com/mirage/ocaml-uri)
library, the old printing function for `Uri.t` was:

```
val pp_hum : Format.formatter -> t -> unit
```

Just adding this annotation results in `Uri.t` values being automatically
pretty printed in this version of utop.

```
val pp_hum : Format.formatter -> t -> unit [@@ocaml.toplevel_printer]
```

* Add cool screenshot to README (ocaml-community/utop#259 @rizo) and update links (ocaml-community/utop#257 @bobot)
* Improve robustness by using more tail-recursive functions (ocaml-community/utop#251 @gpetiot)
* Remove deprecation warnings in newer compilers (ocaml-community/utop#246 @ncihnegn)
* Minimum OCaml version supported is now 4.03.0 (ocaml-community/utop#254 @XVilka)
* Publish API documentation online and add `doc:` entry to opam file (ocaml-community/utop#270 @avsm)
* Port build to dune from jbuilder (ocaml-community/utop#268 @avsm)
* Upgrade local opam metadata to opam 2.0 format (ocaml-community/utop#268 @avsm)
brendanzab added a commit to brendanzab/ocaml-integers that referenced this pull request Nov 11, 2024
As of ocaml-community/utop#269 utop automatically installs printers
marked with the `[@@ocaml.toplevel_printer]` attribute.
brendanzab added a commit to brendanzab/ocaml-integers that referenced this pull request Nov 11, 2024
As of ocaml-community/utop#269 utop automatically installs printers
marked with the `[@@ocaml.toplevel_printer]` attribute.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants