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

Customize printing of one of the mutually recursive types in deriving show #184

Open
ChengCat opened this issue Mar 28, 2019 · 1 comment

Comments

@ChengCat
Copy link

ChengCat commented Mar 28, 2019

For the following program, it seems that I can't have a customized printing function for the type a, while using deriving show to generate the print function for type b.

type a = { x: b; y: int }
and b = A | B a | C a
[@@deriving show]
@michael-schwarz
Copy link

I am facing a similar issue, where I have mutable records with circular references:

type compinfo = {
    mutable cfields: fieldinfo list;
    (** Information about the fields. Notice that each fieldinfo has a
      * pointer back to the host compinfo. This means that you should not
      * share fieldinfo's between two compinfo's *)
    mutable cattr:   attributes;
    [...]
}
and fieldinfo = {
    mutable fcomp: compinfo;
     (** The host structure that contains this field. There can be only one
      * [compinfo] that contains the field. *)
    [...]
}
and [...]

Is there a way of defining a custom printer (or to_yojson in my case specifically) for fieldinfo while using the default one for compinfo?

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