/usr/share/doc/libghc-chasingbottoms-doc/html/index.html is in libghc-chasingbottoms-doc 1.3.0.8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>ChasingBottoms-1.3.0.8: For testing partial and infinite values.</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">ChasingBottoms-1.3.0.8: For testing partial and infinite values.</p></div><div id="content"><div id="description"><h1>ChasingBottoms-1.3.0.8: For testing partial and infinite values.</h1><div class="doc"><p>Do you ever feel the need to test code involving bottoms (e.g. calls to
the <code>error</code> function), or code involving infinite values? Then this
library could be useful for you.
</p><p>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
(<a href="http://www.cse.chalmers.se/~rjmh/QuickCheck/">http://www.cse.chalmers.se/~rjmh/QuickCheck/</a>). With this library you
can do the tests as simply as the following examples show.
</p><p>Testing explicitly for bottoms:
</p><dl><dt><code>> isBottom (head [])</code></dt><dd> <code>True</code>
</dd><dt><code>> isBottom bottom</code></dt><dd> <code>True</code>
</dd><dt><code>> isBottom (\_ -> bottom)</code></dt><dd> <code>False</code>
</dd><dt><code>> isBottom (bottom, bottom)</code></dt><dd> <code>False</code>
</dd></dl><p>Comparing finite, partial values:
</p><dl><dt><code>> ((bottom, 3) :: (Bool, Int)) ==! (bottom, 2+5-4)</code></dt><dd> <code>True</code>
</dd><dt><code>> ((bottom, bottom) :: (Bool, Int)) <! (bottom, 8)</code></dt><dd> <code>True</code>
</dd></dl><p>Showing partial and infinite values (<code>\/!</code> is join and <code>/\!</code> is meet):
</p><dl><dt><code>> approxShow 4 $ (True, bottom) \/! (bottom, 'b')</code></dt><dd> <code>"Just (True, 'b')"</code>
</dd><dt><code>> approxShow 4 $ (True, bottom) /\! (bottom, 'b')</code></dt><dd> <code>"(_|_, _|_)"</code>
</dd><dt><code>> approxShow 4 $ ([1..] :: [Int])</code></dt><dd> <code>"[1, 2, 3, _"</code>
</dd><dt><code>> approxShow 4 $ (cycle [bottom] :: [Bool])</code></dt><dd> <code>"[_|_, _|_, _|_, _"</code>
</dd></dl><p>Approximately comparing infinite, partial values:
</p><dl><dt><code>> approx 100 [2,4..] ==! approx 100 (filter even [1..] :: [Int])</code></dt><dd> <code>True</code>
</dd><dt><code>> approx 100 [2,4..] /=! approx 100 (filter even [bottom..] :: [Int])</code></dt><dd> <code>True</code>
</dd></dl><p>The code above relies on the fact that <code>bottom</code>, just as <code>error
"..."</code>, <code>undefined</code> 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:
</p><dl><dt><code>> timeOut' 1 (reverse [1..5])</code></dt><dd> <code>Value [5,4,3,2,1]</code>
</dd><dt><code>> timeOut' 1 (reverse [1..])</code></dt><dd> <code>NonTermination</code>
</dd></dl><p>The time-out functionality can be used to treat "slow" computations as
bottoms:
</p><dl><dt><code>> let tweak = Tweak { approxDepth = Just 5, timeOutLimit = Just 2 }</code></dt><dd>
</dd><dt><code>> semanticEq tweak (reverse [1..], [1..]) (bottom :: [Int], [1..] :: [Int])</code></dt><dd> <code>True</code>
</dd><dt><code>> let tweak = noTweak { timeOutLimit = Just 2 }</code></dt><dd>
</dd><dt><code>> semanticJoin tweak (reverse [1..], True) ([] :: [Int], bottom)</code></dt><dd> <code>Just ([],True)</code>
</dd></dl><p>This can of course be dangerous:
</p><dl><dt><code>> let tweak = noTweak { timeOutLimit = Just 0 }</code></dt><dd>
</dd><dt><code>> semanticEq tweak (reverse [1..100000000]) (bottom :: [Integer])</code></dt><dd> <code>True</code>
</dd></dl><p>Timeouts can also be applied to <code>IO</code> computations:
</p><dl><dt><code>> let primes = unfoldr (\(x:xs) -> Just (x, filter ((/= 0) . (`mod` x)) xs)) [2..]</code></dt><dd>
</dd><dt><code>> timeOutMicro 100 (print $ filter ((== 1) . (`mod` 83)) primes)</code></dt><dd> <code>[167,499,9NonTermination</code>
</dd><dt><code>> timeOutMicro 100 (print $ take 6 $ filter ((== 1) . (`mod` 83)) primes)</code></dt><dd> <code>[167,499,997,1163,1993NonTermination</code>
</dd><dt><code>> timeOutMicro 100 (print $ take 6 $ filter ((== 1) . (`mod` 83)) primes)</code></dt><dd> <code>[167,499,997,1163,1993,2657]</code>
</dd><dt><code> </code></dt><dd> <code>Value ()</code>
</dd></dl><p>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"
(<a href="http://www.cse.chalmers.se/~nad/publications/danielsson-jansson-mpc2004.html">http://www.cse.chalmers.se/~nad/publications/danielsson-jansson-mpc2004.html</a>).
</p><p>The code has been tested using GHC. Most parts can probably be
ported to other Haskell compilers, but this would require some work.
The <code>TimeOut</code> functions require preemptive scheduling, and most of
the rest requires <code>Data.Generics</code>; <code>isBottom</code> only requires
exceptions, though.
</p></div></div><div id="module-list"><p class="caption">Modules</p><ul><li><span id="control.n.1" class="module collapser" onclick="toggleSection('n.1')">Test</span><ul id="section.n.1" class="show"><li><span class="module"><span id="control.n.1.1" class="collapser" onclick="toggleSection('n.1.1')"> </span><a href="Test-ChasingBottoms.html">Test.ChasingBottoms</a></span><ul id="section.n.1.1" class="show"><li><span class="module"><a href="Test-ChasingBottoms-Approx.html">Test.ChasingBottoms.Approx</a></span></li><li><span class="module"><a href="Test-ChasingBottoms-ApproxShow.html">Test.ChasingBottoms.ApproxShow</a></span></li><li><span class="module"><a href="Test-ChasingBottoms-ContinuousFunctions.html">Test.ChasingBottoms.ContinuousFunctions</a></span></li><li><span class="module"><a href="Test-ChasingBottoms-IsBottom.html">Test.ChasingBottoms.IsBottom</a></span></li><li><span class="module"><a href="Test-ChasingBottoms-Nat.html">Test.ChasingBottoms.Nat</a></span></li><li><span class="module"><a href="Test-ChasingBottoms-SemanticOrd.html">Test.ChasingBottoms.SemanticOrd</a></span></li><li><span class="module"><a href="Test-ChasingBottoms-TimeOut.html">Test.ChasingBottoms.TimeOut</a></span></li></ul></li></ul></li></ul></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.13.2</p></div></body></html>
|