Function
Shell.Inspector
val addInspectMethod: ('a -> 'b) -> unitaddInspectMethod m -> ()
()
Adds the inspector method m to the inspector. An inspector method is a function of type t1 -> t2 that will be applied whenever an object of type t1 is being inspected. On subsequent inspection, values of type t1 are inspected as if they were of type t2.This function raises exception InspectError if m was not compiled with debugging information.
First define the new datatype Foo as follows:
inspectIt returns the following result:MLWorks> inspectIt(); Entering TTY inspector - enter ? for help Value: FOO (10, false) Type: Foo 1: 10 2: false Inspector> q val it : unit = () MLWorks>
Compare this output with the following output, resulting from inspecting Foo after adding a new inspector method using addInspectMethod:
MLWorks> fun inspectFoo (FOO (n,b)) = if b then {value = 0} else {value=n};
val inspectFoo : Foo -> {value: int} = fn
MLWorks> addInspectMethod (inspectFoo);
val it : unit = ()
MLWorks> FOO (10, false);
val it : Foo = FOO (10, false)
MLWorks> inspectIt();
Entering TTY inspector - enter ? for help
Value: FOO (10, false)
Type: Foo
value: 10
Inspector> q
val it : unit = ()
MLWorks>