# \`Format\`-based \`ppx\_deriving.show\` syntax

**URL:** <https://discuss.ocaml.org/t/format-based-ppx-deriving-show-syntax/11532>\
**Category:** Learning\
**Created:** [February 28, 2023, 11:32am UTC](https://discuss.ocaml.org/t/format-based-ppx-deriving-show-syntax/11532 "2023-02-28T11:32:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukstafi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/lukstafi/32/3442_2.png) [@lukstafi](https://discuss.ocaml.org/u/lukstafi)\
**Post date:** [February 28, 2023, 11:32am UTC](https://discuss.ocaml.org/t/format-based-ppx-deriving-show-syntax/11532/1 "2023-02-28T11:32:17Z")

</div>

Continuing the discussion from [Printf @@deriving sexp](https://discuss.ocaml.org/t/printf-deriving-sexp/11517):

Is there a variant of `[%show: core type]` that is a pp printer rather than generating a string?

---

<div class="post-metadata">

**Author:** ![cemerick](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/cemerick/32/1383_2.png) [@cemerick](https://discuss.ocaml.org/u/cemerick)\
**Post date:** [February 28, 2023, 3:55pm UTC](https://discuss.ocaml.org/t/format-based-ppx-deriving-show-syntax/11532/2 "2023-02-28T15:55:54Z")

</div>

No, though `[%pp: ...]` would be a great addition to ppx-deriving.

---

<div class="post-metadata">

**Author:** ![Chet\_Murthy](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/chet_murthy/32/1501_2.png) [@Chet\_Murthy](https://discuss.ocaml.org/u/Chet_Murthy)\
**Post date:** [February 28, 2023, 6:38pm UTC](https://discuss.ocaml.org/t/format-based-ppx-deriving-show-syntax/11532/3 "2023-02-28T18:38:42Z")

</div>

~~It would be a great, great thing to have. The problem I see, is that somebody needs to define the _target_ format. Actually implementing a target format, once defined, would be child’s play. And given the history of people wanting to customize their `ocamlformat` output (which is _entirely_ laudable), probably there need to be a bunch of knobs to turn. This is all straightforward, if only somebody wants to take on the “herding cats” part of the challenge and define this format.~~

~~I hope I’m making sense here when I say “target format”: what I mean is, where should the boxes go, the indents, how much indentation, etc.~~  
Oh ha! I forgot that deriving.show already does this.

---

<div class="post-metadata">

**Author:** ![sim642](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/sim642/32/3597_2.png) [@sim642](https://discuss.ocaml.org/u/sim642)\
**Post date:** [February 28, 2023, 8:37pm UTC](https://discuss.ocaml.org/t/format-based-ppx-deriving-show-syntax/11532/4 "2023-02-28T20:37:48Z")

</div>

ppx\_deriving already derives `pp` functions for type definitions, just not in that inline form. The point was that for `show` functions it does both.  
So the “target format” is already in there and just needs to be exposed in the inline form.

---

<div class="post-metadata">

**Author:** ![Chet\_Murthy](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/chet_murthy/32/1501_2.png) [@Chet\_Murthy](https://discuss.ocaml.org/u/Chet_Murthy)\
**Post date:** [February 28, 2023, 8:59pm UTC](https://discuss.ocaml.org/t/format-based-ppx-deriving-show-syntax/11532/5 "2023-02-28T20:59:07Z")

</div>

Oy, I forgot! Indeed it does!
