[ANN] Genprint - general value printing

This is a patch/switch for basic printing of any value (excepting abstract and polymorphic elements) exactly as printed by the toplevel for a final result.

It’s appropriate for debug purposes where custom crafted or ppx-deriving printers are overkill/inconvenient.

7 Likes

This is a damn useful thing. Often when debugging I just want a quick and dirty way to view the content of a variable and I don’t want to build infrastructure to do it because my only use case is debugging or test case exercises.

I wish something like this was in the mainline of the compiler.

1 Like

Is there any chance of submitting this to the opam repository btw?

as a switch?

Sure, or in whatever other form allows people with OPAM installed to simply get it running at will. Since compiler plugins are obsolete, I imagine a switch is the best option.

I’m not sure what to provide -
if it it might be used for more than testing then perhaps
it shouldn’t have both patches present.
the non-toplevel specific patch would serve for top/byte/opt.

absent any further feedback, I’ll go with that.
thanks…

Perhaps someone else has experience and might be able to offer a suggestion. I’ve never tried building an opam file for an OCaml variant using an external patch…

that wasn’t the issue. Are you aware I mentioned this as already being available on a switch? As it’s in a personal repo there is one extra command to get it installed, listed on the project page.

Having it part of opam means people can find it. Discoverability is important.

I recently became aware of .cmt files and I think it would be better to get the types from them than through a compiler hack.
It would no longer work in a REPL-only environment though.
I think a ppx extension to do the lookup would work.
and of course it can be a standalone library that I will be happy to publish.
I will have a go soon.

1 Like

Genprint is now available as a library. It uses a PPX extension.
Working with OCaml versions from 4.02.

http://github.com/progman1/genprintlib (general value printing in compiled code)

Available through the official opam repository.

1 Like

the link does not seem to be working?

Github is down at the moment: https://www.githubstatus.com/incidents/tq7pm7mn9b1k

Edit: Its back up now