# \#pretty-printing

**URL:** https://discuss.ocaml.org/tag/pretty-printing/239.md

[Latest](https://discuss.ocaml.org/latest.md) · [Categories](https://discuss.ocaml.org/categories.md) · [Tags](https://discuss.ocaml.org/tags.md)

---

## [Using Format.sprintf](https://discuss.ocaml.org/t/using-format-sprintf/17402)

<div class="topic-metadata">

**Author:** [@user1](https://discuss.ocaml.org/u/user1)\
**Replies:** 6\
**Last updated:** [October 19, 2025, 12:11pm UTC](https://discuss.ocaml.org/t/using-format-sprintf/17402 "2025-10-19T12:11:34Z")

</div>

The documentation for Format.sprintf says \[…\] returns a string containing the result of formatting the arguments. But how can that function know how to format the arguments if it is not given a formatter argument? In…

---

## [Pretty-printing with Format](https://discuss.ocaml.org/t/pretty-printing-with-format/17369)

<div class="topic-metadata">

**Author:** [@user1](https://discuss.ocaml.org/u/user1)\
**Replies:** 6\
**Last updated:** [October 14, 2025, 8:52pm UTC](https://discuss.ocaml.org/t/pretty-printing-with-format/17369 "2025-10-14T20:52:52Z")

</div>

In the minimal example below, I define a type t, and then print its values using the function pp. That function has redundant code, which I am trying to factor out (because in my real usecase, there is much more redundan…

---

## [Printf vs. Format?](https://discuss.ocaml.org/t/printf-vs-format/14130)

<div class="topic-metadata">

**Author:** [@ninjaaron](https://discuss.ocaml.org/u/ninjaaron)\
**Replies:** 2\
**Last updated:** [February 20, 2024, 2:45pm UTC](https://discuss.ocaml.org/t/printf-vs-format/14130 "2024-02-20T14:45:27Z")

</div>

I know there are projects like Fmt and ppx derivers that simplify the generation of pretty printers for OCaml objects, but in the general interest of knowing things, today I’m trying to discover the Stdlib way of doing s…

---

## [Print a list of tuples](https://discuss.ocaml.org/t/print-a-list-of-tuples/12502)

<div class="topic-metadata">

**Author:** [@vivanov](https://discuss.ocaml.org/u/vivanov)\
**Replies:** 2\
**Last updated:** [June 29, 2023, 1:14pm UTC](https://discuss.ocaml.org/t/print-a-list-of-tuples/12502 "2023-06-29T13:14:22Z")

</div>

Hey, I am looking for a way to print structures for debugging purposes, and for other purposes. For example, I have a function that produces a list of tuples: List.mapi ( fun i (name, address) -\> Pri…

---

## [PPrint: A tricky case to process nest with ending parentheses](https://discuss.ocaml.org/t/pprint-a-tricky-case-to-process-nest-with-ending-parentheses/11491)

<div class="topic-metadata">

**Author:** [@liweijian](https://discuss.ocaml.org/u/liweijian)\
**Replies:** 1\
**Last updated:** [February 23, 2023, 9:33am UTC](https://discuss.ocaml.org/t/pprint-a-tricky-case-to-process-nest-with-ending-parentheses/11491 "2023-02-23T09:33:59Z")

</div>

I would like to print a list of fun’s like the following, if space permits: (fun1(); fun2(); fun3()) We may notice that: there is not SPACE between the first ( with fun1 there is not SPACE between the last ) with f…

---

## [Pretty printing binary ints](https://discuss.ocaml.org/t/pretty-printing-binary-ints/9062)

<div class="topic-metadata">

**Author:** [@ifazk](https://discuss.ocaml.org/u/ifazk)\
**Replies:** 14\
**Last updated:** [November 1, 2022, 1:12pm UTC](https://discuss.ocaml.org/t/pretty-printing-binary-ints/9062 "2022-11-01T13:12:07Z")

</div>

Stdlib’s Printf allows you to print ints as unsigned octals or hexadecimals, but not as unsigned binary integers. Does anyone have a library that can pretty print ints as binary ints? I’m in the middle of writing one, b…

---

## [\[ANN\] pp\_loc 2.0](https://discuss.ocaml.org/t/ann-pp-loc-2-0/9741)

<div class="topic-metadata">

**Author:** [@Armael](https://discuss.ocaml.org/u/Armael)\
**Replies:** 0\
**Last updated:** [April 28, 2022, 12:33pm UTC](https://discuss.ocaml.org/t/ann-pp-loc-2-0/9741 "2022-04-28T12:33:22Z")

</div>

Do you know how OCaml now displays errors by quoting back part of the source, highlighting the faulty part? For instance, with a single-line error location: File "foo.ml", line 1, characters 12-14: 1 | let foo x = yy + …

---

## [\[ANN\] pp-binary-ints 0.1.1](https://discuss.ocaml.org/t/ann-pp-binary-ints-0-1-1/9080)

<div class="topic-metadata">

**Author:** [@ifazk](https://discuss.ocaml.org/u/ifazk)\
**Replies:** 0\
**Last updated:** [January 1, 2022, 12:55am UTC](https://discuss.ocaml.org/t/ann-pp-binary-ints-0-1-1/9080 "2022-01-01T00:55:45Z")

</div>

Tired of printing octals and hexadecimals and then mentally converting them to bits. Ever wanted to just see the bits in an int? Now you can! Just run opam install pp-binary-ints and off you go: # Pp\_binary\_ints.Int.to…

---

## [Obtaining the necessary type for format strings + arguments](https://discuss.ocaml.org/t/obtaining-the-necessary-type-for-format-strings-arguments/7070)

<div class="topic-metadata">

**Author:** [@cemerick](https://discuss.ocaml.org/u/cemerick)\
**Replies:** 7\
**Last updated:** [January 11, 2021, 5:49pm UTC](https://discuss.ocaml.org/t/obtaining-the-necessary-type-for-format-strings-arguments/7070 "2021-01-11T17:49:27Z")

</div>

I have need of a way to print using any existing printer, with the output stripped of all cuts, linebreaks, and indents (think of presenting messages containing probably-small bits of pretty-printed data to users in conf…

---

## [Providing toplevel pretty-printers for functors](https://discuss.ocaml.org/t/providing-toplevel-pretty-printers-for-functors/2215)

<div class="topic-metadata">

**Author:** [@cfcs](https://discuss.ocaml.org/u/cfcs)\
**Replies:** 0\
**Last updated:** [June 29, 2018, 4:46pm UTC](https://discuss.ocaml.org/t/providing-toplevel-pretty-printers-for-functors/2215 "2018-06-29T16:46:30Z")

</div>

Pretty-printers are provided to the toplevel using the Toploop module, in ipaddr this is done as follows: let printers = \[ "Mymodule.pp" \] let eval\_string ?(print\_outcome = false) ?(err\_formatter = Format.err\_form…
