| ||||
Chasing Bottoms | ||||
Do you ever feel the need to test code involving bottoms (e.g. calls to the error function), or code involving infinite values? Then this library could be useful for you. It is usually easy to get a grip on bottoms by showing a value and waiting to see how much gets printed before the first exception is encountered. However, that quickly gets tiresome and is hard to automate using e.g. QuickCheck (http://www.cs.chalmers.se/~rjmh/QuickCheck/). With this library you can do the tests as simply as the following examples show. Testing explicitly for bottoms:
Comparing finite, partial values:
Showing partial and infinite values (\/! is join and /\! is meet):
Approximately comparing infinite, partial values:
The code above relies on the fact that bottom, just as error "...", undefined and pattern match failures, yield exceptions. Sometimes we are dealing with properly non-terminating computations, such as the following example, and then it can be nice to be able to apply a time-out:
The time-out functionality can be used to treat "slow" computations as bottoms:
This can of course be dangerous:
Timeouts can also be applied to IO computations:
All the type annotations above are required. For the underlying theory and a larger example involving use of QuickCheck, see the article "Chasing Bottoms, A Case Study in Program Verification in the Presence of Partial and Infinite Values" (http://www.cs.chalmers.se/~nad/publications/danielsson-jansson-mpc2004.html). The code has been tested under GHC 6.8. Most parts can probably be ported to other Haskell compilers, but that would require some work. The TimeOut functions require preemptive scheduling, and most of the rest requires Data.Generics; isBottom only requires exceptions, though. Source code: http://www.cs.chalmers.se/~nad/software/ChasingBottoms/ChasingBottoms.tar.gz. | ||||
Modules | ||||
Produced by Haddock version 0.7 |