package dum

  1. Overview
  2. Docs
Inspect the runtime representation of arbitrary OCaml values

Install

Dune Dependency

Authors

Maintainers

Sources

dum-1.0.3.tbz
sha256=645a23503fc8a315530df1b2876c2f785b12cf80f5f692a41eb36e53e2c52651
sha512=f572326af6c295b8c27a54ef6d82309a71b0e31ab5f167b75ac0193350b2f59c8a355e61e83c6ad46e5562b355115f6a116148db097c648abbdd1d3d5573935c

README.md.html

Dum

Purpose

Inspecting arbitrary OCaml values for debugging or just for fun.

Cycles are detected and an additional limit on the size of the dump is set by default. It is therefore safe to use for printing out exceptions in error messages.

Closure fields and object fields are printed.

All the lazy values (forced or not) can be printed but this is optional. Some forced lazy values will always be printed no matter what.

Installation

$ opam update
$ opam install dum

Usage

We do not recommend the use of this library in production code due to its reliance on OCaml internals and unsafe memory access.

$ utop -require dum
# Dum.to_stdout (123, "abc", Not_found, [`A; `B 'x']);;
(123 "abc" object-7 () [ 65 (66 120) ])

A circular list is printed as follows:

# let rec cyc = 1 :: 2 :: 3 :: cyc;;
val cyc : int list = [1; 2; 3; <cycle>]

utop # Dum.to_stdout cyc;;
#0: (1 (2 (3 #0)))

First-class modules can be inspected as well. Here's what I get for the Sys module:

# module type Sys = module type of Sys;;
# Dum.to_stdout (module Sys : Sys);;
(
  ("/home/martin/.opam/4.05.0/bin/utop" "-require" "dum")
  "/home/martin/.opam/4.05.0/bin/utop"
  closure ()
  (1)
  "Unix"
  1
  1
  0
  0
  64
  63
  0
  144115188075855863
  18014398509481983
  #0: closure ()
  -1
  -2
  -3
  -4
  -5
  -6
  -7
  -8
  -9
  -10
  -11
  -12
  -13
  -14
  -15
  -16
  -17
  -18
  -19
  -20
  -21
  -22
  -23
  -24
  -25
  -26
  -27
  -28
  #1: object1 ()
  closure (#0 -6 #1)
  "4.05.0"
  closure ()
  closure ()
)

See dum.mli for more information.

License

GNU LGPL with exception on static linking, see file LICENSE.