# Make generated show function ugly

**URL:** <https://discuss.ocaml.org/t/make-generated-show-function-ugly/18166>\
**Category:** Ecosystem\
**Tags:** show, ppx, deriving\
**Created:** [May 24, 2026, 6:37am UTC](https://discuss.ocaml.org/t/make-generated-show-function-ugly/18166 "2026-05-24T06:37:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nobrowser](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nobrowser/32/2099_2.png) [@nobrowser](https://discuss.ocaml.org/u/nobrowser)\
**Post date:** [May 24, 2026, 6:37am UTC](https://discuss.ocaml.org/t/make-generated-show-function-ugly/18166/1 "2026-05-24T06:37:07Z")

</div>

I tried to use ppx-deriving and its `show` plugin to get easy stringification for my ADTs. But in the context of my project I want it to be easily machine readable, while it seems that `show` is meant for pretty-printing. For example if I have this:

```auto
type long_foo = FooooooooooLooooooooong of string
[@@deriving show]

```

then the result of

```auto
show_long_foo ( FooooooooooLooooooooong "LOOOOOOOOOOOOOOOOOOONGFOOOOOO" )

```

will be something like

```auto
(FooooooooooLooooooooong
    "LOOOOOOOOOOOOOOOOOOONGFOOOOOO")

```

when I really want it on the same line, with a single space in between, no matter how long that line will be. Is there a tweak I can make to the deriving annotation, or to the way I link the ppx? If there is I can’t find it in the obvious documentation places 👅

Thanks.

---

<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:** [May 24, 2026, 8:58am UTC](https://discuss.ocaml.org/t/make-generated-show-function-ugly/18166/2 "2026-05-24T08:58:04Z")

</div>

> [@nobrowser](#):
>
> But in the context of my project I want it to be easily machine readable, while it seems that `show` is meant for pretty-printing.

That is correct. If you want machine readability, it’d be much better to use formats and (de)serializers designed for this, e.g. JSON, S-exp, etc. There are many ppx-s for such things as well.

> [@nobrowser](#):
>
> when I really want it on the same line, with a single space in between, no matter how long that line will be.

The show plugin also creates a more general `pp` function, which can be used together with the standard `Format` module. There it’s possible to change the margin to something very large that avoids the automatic line-breaking offered by `Format`: [OCaml library : Format](https://ocaml.org/manual/5.4/api/Format.html#1_Geometry).
