1 Using MLWorks interactively

1.10 Examining ML values

You can look at the details of an ML value using the inspector. To see it in action, define a value as follows:

MLWorks> val bar = ("hello", [[1,2], [3,4] @ [5]]);
val bar : (string * int list list) = ("hello", [[1,2], [3,4, 5]]); 
MLWorks> 

Now choose Action > Inspect. MLWorks brings up an inspector.

Figure 1.4 The MLWorks inspector.

The inspector contains details of the item last defined in the listener before it was invoked.

The inspector has several fields: the Source field shows the declaration MLWorks read which defined the value being examined, and the Value and Type fields show its value and type, as you would expect.

The Components field shows a graphical representation of the value. Currently this is not very informative; however, it can be expanded to show the structure of the value. Double-click on the value to expand it one level, showing the components. The second component is a list, and can be further expanded in the same way. It may be convenient to resize the inspector window using your window manager.

Figure 1.5 The inspector's graphical representation of a value.

By invoking the inspector from the listener you can only inspect the most recently defined item. Thus, if you already had an inspector on screen, it would not instantly inspect the declaration of bar.

One way to fix this is to turn on the Main > Auto-selection option. This makes the inspector show values as they are defined from then on. (So you would still have to re-evaluate the declaration of bar to get it to appear.)

Another way to inspect an older item is to look at it in the context browser. To do this, select Tools > Context Browser. The context browser appears.

Figure 1.6 The MLWorks context browser.

It contains an up-to-date list of all the bindings you have created in the interactive environment. To inspect any item, click on it in the list, and then choose Action > Inspect from the context browser.

Similar to the context browser is the system browser. With this tool you can browse the built-in parts of MLWorks. To do this, select Tools > System Browser. The system browser appears.

Figure 1.7 The MLWorks system browser.

With the system browser you can browse the built in MLWorks and Shell structures, and the Standard ML Basis library General structure. There are other identifiers available unqualified at top level, such as the bool datatype and the * function, which are as defined by the Standard ML Basis library -- with the exception of the function use, which we saw in Section 1.7 as the function invoked by the listener's File > Use File menu item. The use function is defined by Shell.

If you want to see what is inside a particular structure, double-click on it. The system browser shows you the contents of the structure. To see this in action, double-click on Shell.

Figure 1.8 Browsing the Shell structure.

You can browse the substructures of Shell by further double-clicking.

Every time you click on an item, the system browser puts the full qualified name of that item in the Selection field. If you want to use the full qualified name of an item somewhere, you can save typing it out by selecting it in the system browser and copying it with Edit > Copy, or with mouse selection, for subsequent pasting in another tool such as a listener.

For more details of the system browser, context browser, and inspector, see Chapter 4, "Examining Objects".


MLWorks User Guide (UNIX version 1.0) - 3 DEC 1996

Generated with Harlequin WebMaker