For the purpose of construction good documentation automatically, it is useful to specify the type of value typically returned by a function or method. For example, the function isModule returns a boolean value, and this is specified when creating the method function with the option TypicalValue as follows.
isModule = method(TypicalValue => Boolean)
Other functions, such as prune, return values of various types, depending on the type of the arguments provided. To install a function f as the handler for prune applied to a matrix, we would normally use the following statement.
prune Matrix := fTo specify that the value typically returned is a matrix (of class Matrix), we replace f by Matrix => f, as follows.
prune Matrix := Matrix => fHere is the way our code looks.
i1 : code(prune, Matrix) |
The information is stored in the hash table typicalValues, and can be recovered like this.
i2 : typicalValues#(prune,Matrix) |
Warning: don't imagine that a definition of the form
f = t -> (...)can be replaced with a declaration of the following form.
f = X => t -> (...)The difference here is that here we are using simple assignment, rather than installing a method. To document the return type is X in this case, make an entry in typicalValues directly.
f = t -> (...) typicalValues#f = X