ABSTRACT

It became clear in the previous chapter that a term-rewriting system has to cope with exceptional and unwanted events such as an attempt to read the head element of an empty list. It became equally clear that once such an event had occurred, it was necessary to propagate the error through a whole series of term rewrites, eventually returning an error of the correct type. As a consequence, every domain involved in the computation has to be equipped with an error element of the correct type. For example, a Boolean domain of just two constants has to be extended to a larger domain that includes an error element error ∈ Bool2 to give a new set https://www.w3.org/1998/Math/MathML"> B o o l 2 = { t r u e , f a l s e , e r r o r } https://s3-euw1-ap-pe-df-pch-content-public-p.s3.eu-west-1.amazonaws.com/9780203211991/94c3b92a-0a16-4a4e-9014-02b93290d004/content/math_476_B.tif" xmlns:xlink="https://www.w3.org/1999/xlink"/> A Boolean error might result if one of the arguments in a Boolean function were itself an error in the domain of that argument. This procedure works well enough, but it gives the error element in any domain exactly the same status as every other element of the domain. We might instinctively feel that an error element is rather less useful or perhaps less defined than the acceptable, fully defined answers in a domain and might therefore wish to distinguish between the two forms of element.