diff options
author | Enrico Tassi <Enrico.Tassi@inria.fr> | 2014-12-24 14:34:51 +0100 |
---|---|---|
committer | Enrico Tassi <Enrico.Tassi@inria.fr> | 2014-12-26 15:07:03 +0100 |
commit | 5d6106a075b79abbb92b03bbca7b13a517cf4925 (patch) | |
tree | 8dd90fb5483a623b27f3d62a18e7a6cf088fc4af | |
parent | dca4b978ff8bfa2eeee864edac4199d9d9df3d5e (diff) |
Term: include a function to print terms
I find it very odd not to have a pretty printer for terms than can
be called from *everywhere*. This commit sticks in Term a long spaghetti
to let Printer install a printing function.
-rw-r--r-- | kernel/term.ml | 7 | ||||
-rw-r--r-- | kernel/term.mli | 6 | ||||
-rw-r--r-- | printing/printer.ml | 2 |
3 files changed, 15 insertions, 0 deletions
diff --git a/kernel/term.ml b/kernel/term.ml index 3adfa5e37..508d9b81a 100644 --- a/kernel/term.ml +++ b/kernel/term.ml @@ -679,3 +679,10 @@ let kind_of_type t = match kind_of_term t with | Proj _ | Case _ | Fix _ | CoFix _ | Ind _) -> AtomicType (t,[||]) | (Lambda _ | Construct _) -> failwith "Not a type" + +(* This is not dead code, it is there to have a constr printer available + * everywhere *) +let print_val, print_hook = + Hook.make ~default:(fun x -> Pp.str"constr printer not installed") () +let print t = Hook.get print_val t + diff --git a/kernel/term.mli b/kernel/term.mli index c5e85b1e5..972f7d5d8 100644 --- a/kernel/term.mli +++ b/kernel/term.mli @@ -480,3 +480,9 @@ val hcons_constr : constr -> constr val hcons_types : types -> types (** Alias for [Constr.hashcons] *) + + +(********************** debugging ************************************) +val print_hook : (constr -> Pp.std_ppcmds) Hook.t +val print : constr -> Pp.std_ppcmds + diff --git a/printing/printer.ml b/printing/printer.ml index 38b5e0bfd..1218c49b3 100644 --- a/printing/printer.ml +++ b/printing/printer.ml @@ -67,6 +67,8 @@ let pr_constr t = let (sigma, env) = get_current_context () in pr_constr_env env sigma t +let () = Hook.set Term.print_hook pr_constr + let pr_open_lconstr (_,c) = pr_lconstr c let pr_open_constr (_,c) = pr_constr c |