Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Module Gprinttyp
This module provides function for printing type expressions as digraph using graphviz format. This is mostly aimed at providing a better representation of type expressions during debugging session.
A type node is printed as
.------------.
| <desc> id |---->
| |--->
.------------.
where the description part might be:
a path: list/8!
a type variable: 'name, α, β, γ
* for tuples
→ for arrows type
an universal type variable: [β]∀, 'name ∀, ...
[mod X with ...] for a first class module
∀ for a universal type binder
The more complex encoding for polymorphic variants and object types uses nodes as head of the subgraph representing those types
[obj...] for the head of an object subgraph
[Nil] for the end of an object subgraph
[Row...] for the head of a polymorphic variant subgraph
[Subst] for a temporary substitution node
Then each nodes is relied by arrows to any of its children types.
Type variables, universal type variables, Nil, and Subst nodes don't have children.
For tuples, the children types are the elements of the tuple. For instance, int * float is represented as
Moreover, type abbreviations might be linked to the expanded nodes. If I define: type 'a pair = 'a * 'a, a type expression int pair might correspond to the nodes:
[Subst] node are children are the type graph guarded by the substitution node, and an eventual link to the parent row variable.
The children of first-class modules are the type expressions that may appear in the right hand side of constraints. For instance, module M with type t = 'a and type u = 'b is represented as
.----------------------. 0 .-----.
| [mod M with t, u] 11 |-------->| 𝛼 12|
.----------------------. .-----
|
| 1
v
.------.
| 𝛽 13 |
.------.
The children of obj (resp. row) are the methods (resp. constructor) of the object type (resp. polymorphic variant). Each method is then linked to its type. To make them easier to read they are grouped inside graphviz cluster. For instance, <a:int; m:'self; ..> as 'self will be represented as:
Full version of types that allow to print any kind of graph element
val params :
?elide_links:bool ->?expansion_as_hyperedge:bool ->?short_ids:bool ->?colorize:bool ->?follow_expansions:bool ->unit ->params
Choice of details for printing type graphes:
if elide_links is true link nodes are not displayed (default:true)
with expansion_as_hyperedge, memoized constructor expansion are displayed as a hyperedge between the node storing the memoized expansion, the expanded node and the expansion (default:false).
with short_ids, we use an independent counter for node ids, in order to have shorter ids for small digraphs (default:true).
with colorize nodes are colorized according to their typechecker ids (default:true).
with follow_expansions, we add memoized type constructor expansions to the digraph (default:true).
val update_params :
?elide_links:bool ->?expansion_as_hyperedge:bool ->?short_ids:bool ->?colorize:bool ->?follow_expansions:bool ->params->params
register_subgraph params tys groups together all types reachable from tys at this point in printed digraphs, until forget is called
val forget : unit -> unit
Forget all recorded context types
type'a context
Contextual information
Those functions can be used to modify the filename of the generated digraphs. Use those functions to provide contextual information on a graph emitted during an execution trace.