Skip to content

Commit

Permalink
Move "print length" into Globals
Browse files Browse the repository at this point in the history
As per request from @mn200
  • Loading branch information
hrutvik committed May 8, 2024
1 parent 5b6290f commit 87fb3d2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
22 changes: 22 additions & 0 deletions help/Docfiles/Globals.max_print_length.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
\DOC max_print_length

\TYPE {max_print_length : int ref}

\SYNOPSIS
Sets a length bound on pretty printing for list forms.

\DESCRIBE

Defines the maximum number of elements that the pretty printer will print for
list forms. This closely mirrors {Globals.max_print_depth}: remaining elements
are abbreviated by {...}, and the default value of {~1} means `print all
elements'.

\FAILURE
Never fails.

\SEEALSO
Globals.max_print_depth


\ENDDOC
1 change: 0 additions & 1 deletion src/monad/monadsyntax.sig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ sig
val temp_disable_monadsyntax : unit -> unit

val print_explicit_monadic_lets : bool -> unit
val set_monad_print_length : int option -> unit

type monadinfo =
{ bind : term,
Expand Down
8 changes: 2 additions & 6 deletions src/monad/monadsyntax.sml
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ end handle HOL_ERR _ => NONE


val explicit_mlets = ref false;
val monad_print_length = ref (~1);

fun print_monads (tyg, tmg) backend sysprinter ppfns (p,l,r) depth t = let
open term_pp_types term_grammar smpp term_pp_utils
Expand Down Expand Up @@ -349,7 +348,8 @@ in
ublock PP.CONSISTENT 0
(strn "do" >> brk(1,2) >>
getbvs >- (fn oldbvs =>
concatWith (strn ";" >> brk(1,2)) (pr_action_list (!monad_print_length) actions) >>
concatWith (strn ";" >> brk(1,2))
(pr_action_list (!Globals.max_print_length) actions) >>
brk(1,0) >>
strn "od" >> setbvs oldbvs))
end
Expand Down Expand Up @@ -499,10 +499,6 @@ val enable_monadsyntax = add_monadsyntax
val temp_enable_monadsyntax = temp_add_monadsyntax

fun print_explicit_monadic_lets b = (explicit_mlets := b);
fun set_monad_print_length NONE = (monad_print_length := ~1)
| set_monad_print_length (SOME n) =
if n < 0 then raise ERR "set_monad_print_length" "Cannot set a negative length!"
else (monad_print_length := n)

val _ = TexTokenMap.temp_TeX_notation
{hol = "<-", TeX = ("\\HOLTokenLeftmap{}", 1)}
Expand Down
1 change: 1 addition & 0 deletions src/prekernel/Globals.sig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ sig
val show_scrub : bool ref
val linewidth : int ref
val max_print_depth : int ref
val max_print_length : int ref
val type_pp_prefix : string ref
val type_pp_suffix : string ref
val term_pp_prefix : string ref
Expand Down
6 changes: 6 additions & 0 deletions src/prekernel/Globals.sml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ val max_print_depth = ref ~1

val pp_flags = {show_types = ref false, show_numeral_types = ref false}

(*---------------------------------------------------------------------------*
* Controls how many elements to print for list forms. Mirrors print depth. *
*---------------------------------------------------------------------------*)

val max_print_length = ref ~1

(*---------------------------------------------------------------------------*
* For prettyprinting type information in a term. *
*---------------------------------------------------------------------------*)
Expand Down

0 comments on commit 87fb3d2

Please sign in to comment.