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

Package ppx_show seems breaking in UTop #1

Closed
sheepduke opened this issue Feb 27, 2021 · 1 comment
Closed

Package ppx_show seems breaking in UTop #1

sheepduke opened this issue Feb 27, 2021 · 1 comment

Comments

@sheepduke
Copy link

Description

First of all, everything works when building with dune.

The package ppx_show (version 0.2.0) does not work in UTop. Also, when it is loaded, ppx_compare will stop working.

How to reproduce

Start utop and run the following commands in it:

utop # #require "ppx_show";;
utop # type 'a binary_tree =
  | Empty
  | Node of 'a * 'a binary_tree * 'a binary_tree
[@@deriving show];;
Error: Error while running external preprocessor
Command line: /home/sheep/.opam/default/lib/ppx_show/./ppx.exe --as-ppx '/tmp/camlppx21011f' '/tmp/camlppxb4b1ef'

Then restart utop and run:

utop # #require "ppx_show";;
utop # #require "ppx_compare";;
utop # type 'a binary_tree =
  | Empty
  | Node of 'a * 'a binary_tree * 'a binary_tree
[@@deriving show];;
Error: Error while running external preprocessor
Command line: /home/sheep/.opam/default/lib/ppx_show/./ppx.exe --as-ppx '/tmp/camlppx137bfb' '/tmp/camlppx93ab35'

However, ppx_compare works without loading ppx_show:

utop # #require "ppx_compare";;
utop # type 'a binary_tree =
  | Empty
  | Node of 'a * 'a binary_tree * 'a binary_tree
[@@deriving equal,compare];;
type 'a binary_tree = Empty | Node of 'a * 'a binary_tree * 'a binary_tree
val equal_binary_tree :
  ('a -> 'a -> bool) -> 'a binary_tree -> 'a binary_tree -> bool = <fun>
val compare_binary_tree :
  ('a -> 'a -> int) -> 'a binary_tree -> 'a binary_tree -> int = <fun>

In addition, the following dune file simply works:

(library
 (name mylib)
 (libraries ppx_show.runtime)
 (preprocess (pps ppx_compare ppx_show)))

The current workaround is to use ppx_deriving.show in order to use the [@@deriving show] ppx.

Am I missing anything, or it is a bug of ppx_show library?

@thierry-martinez
Copy link
Owner

This should be fixed now! Thank you very much for the report. Another workaround would have been (the problem was to give a name to the current module in the toplevel for the path):

type 'a binary_tree =
  | Empty
  | Node of 'a * 'a binary_tree * 'a binary_tree
[@@deriving show {with_path=false}];;

Note that you need to #require "ppx_show.runtime" as well.

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

No branches or pull requests

2 participants