This file is indexed.

/usr/share/doc/libghc-non-negative-doc/html/Numeric-NonNegative-Class.html is in libghc-non-negative-doc 0.1-5build1.

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
<!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>Numeric.NonNegative.Class</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();setSynopsis("mini_Numeric-NonNegative-Class.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Numeric-NonNegative-Class.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">non-negative-0.1: Non-negative numbers</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>Haskell 98</td></tr><tr><th>Stability</th><td>stable</td></tr><tr><th>Maintainer</th><td>haskell@henning-thielemann.de</td></tr><tr><th>Safe Haskell</th><td>Safe-Inferred</td></tr></table><p class="caption">Numeric.NonNegative.Class</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>A type class for non-negative numbers.
Prominent instances are <code><a href="Numeric-NonNegative-Wrapper.html#t:T">T</a></code> and peano numbers.
This class cannot do any checks,
but it let you show to the user what arguments your function expects.
Thus you must define class instances with care.
In fact many standard functions (<code><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-List.html#v:take">take</a></code>, '(!!)', ...)
should have this type class constraint.
</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">class</span> (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Ord.html#t:Ord">Ord</a> a, <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Monoid.html#t:Monoid">Monoid</a> a) =&gt; <a href="#t:C">C</a> a  <span class="keyword">where</span><ul class="subs"><li><a href="#v:split">split</a> :: a -&gt; a -&gt; (a, (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a>, a))</li></ul></li><li class="src short"><a href="#v:splitDefault">splitDefault</a> :: (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Ord.html#t:Ord">Ord</a> b, <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Prelude.html#t:Num">Num</a> b) =&gt; (a -&gt; b) -&gt; (b -&gt; a) -&gt; a -&gt; a -&gt; (a, (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a>, a))</li><li class="src short"><a href="#v:-45--124-">(-|)</a> :: <a href="Numeric-NonNegative-Class.html#t:C">C</a> a =&gt; a -&gt; a -&gt; a</li><li class="src short"><a href="#v:zero">zero</a> :: <a href="Numeric-NonNegative-Class.html#t:C">C</a> a =&gt; a</li><li class="src short"><a href="#v:add">add</a> :: <a href="Numeric-NonNegative-Class.html#t:C">C</a> a =&gt; a -&gt; a -&gt; a</li><li class="src short"><a href="#v:sum">sum</a> :: <a href="Numeric-NonNegative-Class.html#t:C">C</a> a =&gt; [a] -&gt; a</li><li class="src short"><a href="#v:maximum">maximum</a> :: <a href="Numeric-NonNegative-Class.html#t:C">C</a> a =&gt; [a] -&gt; a</li><li class="src short"><a href="#v:switchDifferenceNegative">switchDifferenceNegative</a> :: <a href="Numeric-NonNegative-Class.html#t:C">C</a> a =&gt; a -&gt; a -&gt; (a -&gt; b) -&gt; (a -&gt; b) -&gt; b</li><li class="src short"><a href="#v:switchDifferenceOrdering">switchDifferenceOrdering</a> :: <a href="Numeric-NonNegative-Class.html#t:C">C</a> a =&gt; a -&gt; a -&gt; b -&gt; (a -&gt; b) -&gt; (a -&gt; b) -&gt; b</li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><span class="keyword">class</span> (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Ord.html#t:Ord">Ord</a> a, <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Monoid.html#t:Monoid">Monoid</a> a) =&gt; <a name="t:C" class="def">C</a> a  <span class="keyword">where</span><a href="src/Numeric-NonNegative-Class.html#C" class="link">Source</a></p><div class="doc"><p>Instances of this class must ensure non-negative values.
We cannot enforce this by types, but the type class constraint <code>NonNegative.C</code>
avoids accidental usage of types which allow for negative numbers.
</p><p>The Monoid superclass contributes a zero and an addition.
</p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:split" class="def">split</a> :: a -&gt; a -&gt; (a, (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a>, a))<a href="src/Numeric-NonNegative-Class.html#split" class="link">Source</a></p><div class="doc"><p><code>split x y == (m,(b,d))</code> means that
   <code>b == (x&lt;=y)</code>,
   <code>m == min x y</code>,
   <code>d == max x y - min x y</code>, that is <code>d == abs(x-y)</code>.
</p><p>We have chosen this function as base function,
   since it provides comparison and subtraction in one go,
   which is important for replacing common structures like
</p><pre> if x&lt;=y
   then f(x-y)
   else g(y-x)
</pre><p>that lead to a memory leak for peano numbers.
   We have choosen the simple check <code>x&lt;=y</code>
   instead of a full-blown <code>compare</code>,
   since we want <code>Zero &lt;= undefined</code> for peano numbers.
   Because of undefined values <code><a href="Numeric-NonNegative-Class.html#v:split">split</a></code> is in general
   not commutative in the sense
</p><pre> let (m0,(b0,d0)) = split x y
     (m1,(b1,d1)) = split y x
 in  m0==m1 &amp;&amp; d0==d1
</pre><p>The result values are in the order
   in which they are generated for Peano numbers.
   We have chosen the nested pair instead of a triple
   in order to prevent a memory leak
   that occurs if you only use <code>b</code> and <code>d</code> and ignore <code>m</code>.
   This is demonstrated by test cases
   Chunky.splitSpaceLeak3 and Chunky.splitSpaceLeak4.
</p></div></div><div class="subs instances"><p id="control.i:C" class="caption collapser" onclick="toggleSection('i:C')">Instances</p><div id="section.i:C" class="show"><table><tr><td class="src">(<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Ord.html#t:Ord">Ord</a> a, <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Prelude.html#t:Num">Num</a> a) =&gt; <a href="Numeric-NonNegative-Class.html#t:C">C</a> (<a href="Numeric-NonNegative-Wrapper.html#t:T">T</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Numeric-NonNegative-Class.html#t:C">C</a> a =&gt; <a href="Numeric-NonNegative-Class.html#t:C">C</a> (<a href="Numeric-NonNegative-Chunky.html#t:T">T</a> a)</td><td class="doc"><p>This instance is not correct with respect to the equality check
if the involved numbers contain zero chunks.
</p></td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:splitDefault" class="def">splitDefault</a> :: (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Ord.html#t:Ord">Ord</a> b, <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Prelude.html#t:Num">Num</a> b) =&gt; (a -&gt; b) -&gt; (b -&gt; a) -&gt; a -&gt; a -&gt; (a, (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Bool.html#t:Bool">Bool</a>, a))<a href="src/Numeric-NonNegative-Class.html#splitDefault" class="link">Source</a></p><div class="doc"><p>Default implementation for wrapped types of <code><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Data-Ord.html#t:Ord">Ord</a></code> and <code><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Prelude.html#t:Num">Num</a></code> class.
</p></div></div><div class="top"><p class="src"><a name="v:-45--124-" class="def">(-|)</a> :: <a href="Numeric-NonNegative-Class.html#t:C">C</a> a =&gt; a -&gt; a -&gt; a<a href="src/Numeric-NonNegative-Class.html#-%7C" class="link">Source</a></p><div class="doc"><pre>x -| y == max 0 (x-y)</pre><p>The default implementation is not efficient,
because it compares the values and then subtracts, again, if safe.
<code>max 0 (x-y)</code> is more elegant and efficient
but not possible in the general case,
since <code>x-y</code> may already yield a negative number.
</p></div></div><div class="top"><p class="src"><a name="v:zero" class="def">zero</a> :: <a href="Numeric-NonNegative-Class.html#t:C">C</a> a =&gt; a<a href="src/Numeric-NonNegative-Class.html#zero" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:add" class="def">add</a> :: <a href="Numeric-NonNegative-Class.html#t:C">C</a> a =&gt; a -&gt; a -&gt; a<a href="src/Numeric-NonNegative-Class.html#add" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:sum" class="def">sum</a> :: <a href="Numeric-NonNegative-Class.html#t:C">C</a> a =&gt; [a] -&gt; a<a href="src/Numeric-NonNegative-Class.html#sum" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:maximum" class="def">maximum</a> :: <a href="Numeric-NonNegative-Class.html#t:C">C</a> a =&gt; [a] -&gt; a<a href="src/Numeric-NonNegative-Class.html#maximum" class="link">Source</a></p><div class="doc"><p>Left biased maximum of a list of numbers that can also be empty.
It holds
</p><pre> maximum [] == zero
</pre></div></div><div class="top"><p class="src"><a name="v:switchDifferenceNegative" class="def">switchDifferenceNegative</a> :: <a href="Numeric-NonNegative-Class.html#t:C">C</a> a =&gt; a -&gt; a -&gt; (a -&gt; b) -&gt; (a -&gt; b) -&gt; b<a href="src/Numeric-NonNegative-Class.html#switchDifferenceNegative" class="link">Source</a></p><div class="doc"><p>In <code>switchDifferenceNegative x y branchXminusY branchYminusX</code>
the function <code>branchXminusY</code> is applied to <code>x-y</code>
if this difference is non-negative,
otherwise <code>branchYminusX</code> is applied to <code>y-x</code>.
</p></div></div><div class="top"><p class="src"><a name="v:switchDifferenceOrdering" class="def">switchDifferenceOrdering</a> :: <a href="Numeric-NonNegative-Class.html#t:C">C</a> a =&gt; a -&gt; a -&gt; b -&gt; (a -&gt; b) -&gt; (a -&gt; b) -&gt; b<a href="src/Numeric-NonNegative-Class.html#switchDifferenceOrdering" class="link">Source</a></p><div class="doc"><p>In <code>switchDifferenceOrdering x y branchZero branchXminusY branchYminusX</code>
</p></div></div></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>