<A HREF="manual_c.htm"><img align=center src="contents.gif" ALT="Contents"></A> Up Previous Next

Use "show'' to display results +u,-u


In normal use, Hugs displays the value of each expression entered into the interpreter by applying the standard prelude function:
 show :: Show a => a -> String
to it and displaying the resulting string of characters. This approach works well for any value whose type is an instance of the standard Show class; for example, the prelude defines instances of Show for all of the built-in datatypes. It is also easy for users to extend the class with new datatypes, either by providing a handwritten instance declaration, or by requesting an automatically derived instance as part of the datatype definition, as in:
 data Rainbow = Red | Orange | Yellow | Green | Blue | Indigo | Violet
                deriving Show
The advantage of using show is that it allows programmers to display the results of evaluations in whatever form is most convenient for users---which is not always the same as the way in which the values are represented.

This is probably all that most users will ever need. However, there are some circumstances where it is not convenient, for example, for certain kinds of debugging or for work with datatypes that are not instances of Show. In these situations, the -u option can be used to prevent the use of show. In its place, Hugs will use a built-in printing mechanism that works for all datatypes, and uses the representation of a value to determine what gets printed. At any point, the default printing mechanism can be restored by setting +u.