simplify Signatures by requiring debug [pprint] everywhere

This commit is contained in:
Gabriel Scherer 2022-05-03 10:12:24 +02:00 committed by François Pottier
parent ea30d554e8
commit 54021e46bd
6 changed files with 22 additions and 17 deletions

View File

@ -22,8 +22,8 @@ module O = struct
let inject n =
2 * n
type 'a structure =
'a S.structure
type 'a structure = 'a S.structure
let pprint = S.pprint
type ty =
F.nominal_type

View File

@ -126,6 +126,14 @@ type 'a data = {
mutable mark: mark;
}
(* A printer (for debugging purposes). *)
let pprint elem data =
let open PPrint in
utf8format "@%d[%d]" data.id data.rank ^^
S.pprint elem data.structure
(* [status] and [mark] are currently not printed. *)
(* This exception is raised when a rigid variable escapes its scope, that is,
when it is unified with (or becomes a child of) a variable of lesser rank.
At present, this exception does not carry any data; we do not yet know how
@ -154,6 +162,8 @@ module Data = struct
type 'a structure =
'a data
let pprint = pprint
let id data =
data.id

View File

@ -53,6 +53,10 @@ module type SSTRUCTURE = sig
which indicates the presence of an equality constraint. *)
type 'a structure
(**[pprint] is a structure printer, parameterized over a child printer.
It is used for debugging purposes only. *)
val pprint: ('a -> PPrint.document) -> 'a structure -> PPrint.document
end
(* -------------------------------------------------------------------------- *)
@ -216,19 +220,6 @@ module type STRUCTURE_LEAF = sig
end
(* [HSTRUCTURE] describes an input of [Solver.Make]. *)
module type HSTRUCTURE = sig
(** @inline *)
include GSTRUCTURE
(**[pprint] is a structure printer, parameterized over a child printer.
It is used for debugging purposes only. *)
val pprint: ('a -> PPrint.document) -> 'a structure -> PPrint.document
end
(* -------------------------------------------------------------------------- *)
(* [MUNIFIER] describes a fragment of the functionality offered by the

View File

@ -13,7 +13,7 @@ open Signatures
module Make
(X : TEVAR)
(S : HSTRUCTURE)
(S : GSTRUCTURE)
(O : OUTPUT with type 'a structure = 'a S.structure)
= struct
@ -362,6 +362,7 @@ end (* UVar *)
module D =
Decoder.Make (G.Data) (U) (struct
include O
let pprint = G.Data.pprint
let structure (s : O.ty U.structure) : O.ty =
O.structure (OS.project_nonleaf (G.Data.project s))
end)

View File

@ -31,7 +31,7 @@ open Signatures
elaboration in order to construct an explicitly-typed program. *)
module Make
(X : sig (** @inline *) include TEVAR end)
(S : sig (** @inline *) include HSTRUCTURE end)
(S : sig (** @inline *) include GSTRUCTURE end)
(O : sig (** @inline *) include OUTPUT
with type 'a structure = 'a S.structure end)
: sig

View File

@ -61,4 +61,7 @@ module Option (S : GSTRUCTURE) = struct
let project_nonleaf =
Option.get
let pprint elem os =
PPrint.OCaml.option (S.pprint elem) os
end (* Option *)