SML# Document Version 4.0.0
13 SML# feature: dynamic types and typed manipulation of JSON

13.3 Pretty printer

In the SML#’s interactive session, ML values of arbitrary types are printed to the standard output. This feature is realized on top of the reification mechanism. The user is allowed to invoke the printer of the interactive session from user programs. The following functions are available:

  • Dynamic.pp : [’a#reify. ’a -> unit]. This pretty-prints the given ML value of arbitrary type to the standard output. The format is similar to the interactive session. This is useful for print debug.

  • Dynamic.format : [’a#reify. ’a -> string]. Instead of printing to standard output, this returns a string of the pretty-printed ML value.

These functions can be used in polymorphic functions. Note that using these functions in a polymorphic function may change the type of the function by adding reify kind to the type of the function.