Try RTT
RTT is a prototype implementation of run-time typing in OCaml. It allows programmers to use functions such as Rtt.to_string: α → string (for all α). It is fully automatic, and provides the actual run-time type of values (including when it is more precise than the static type, because of polymorphism). See the RTT home page for full documentation.
Quick example Type (or paste): Rtt.to_string ["Hello"; "world"]
API essentials (from module Rtt):
val to_string : α → string
Return a string representation of a value, in one line.
val pprint :
?depth:int → ?unfold:bool → α → Format.formatter → unit
Pretty-print a value on the given formatter (see
Rtt_ops).
type rttype
The type of runtime representations of types (see
Rtt_type).
val typeof : α → rttype
Return the dynamic type of a value.
type untyped
A type for manipulating any value with its dynamic type embedded.
val untype : α → untyped
Forget the static type of a value, and embedd its dynamic type.
type value_kind
val destruct : untyped → value_kind
Perform one level of matching on an untyped value.
val cast : untyped → α option
Safely cast an untyped value to an expected type, or return
None.Caveats:
- Parsing sometimes strips the input non-deterministically.
- Monomorphic types are not supported and will break Try RTT.

| Commands | Effects |
|---|---|
| Enter / Return | Submit code |
| Up / Down | Cycle through history |
| Shift + Enter | Multiline edition |